Giter VIP home page Giter VIP logo

askmanta's Issues

Install fails bc of configuation requirements

If I install askmanta without first configuring environmental variables, it gives me this error:

  Running setup.py (path:/var/folders/4m/zzbwyss11r77z85h92r63lcr0000gn/T/pip-VuyTdS-build/setup.py) egg_info for package from git+https://github.com/stdbrouw/askmanta
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/var/folders/4m/zzbwyss11r77z85h92r63lcr0000gn/T/pip-VuyTdS-build/setup.py", line 3, in <module>
        from askmanta import VERSION
      File "askmanta/__init__.py", line 5, in <module>
        import job, manifest
      File "askmanta/job.py", line 5, in <module>
        from askmanta.environment import client
      File "askmanta/environment.py", line 9, in <module>
        if 'localhost' in os.environ['MANTA_URL']:
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/UserDict.py", line 23, in __getitem__
        raise KeyError(key)
    KeyError: 'MANTA_URL'

This should be somehow covered on initialization of jobs etc or more explicitly stated.

i wrote a connect module but wasn't sure how to integrate it, hence no PR ;).

import os
import logging
import manta 

logging.basicConfig()

MANTA_URL = os.getenv('MANTA_URL')
MANTA_USER = os.getenv('MANTA_URL')
MANTA_KEY_ID = os.getenv('MANTA_KEY_ID')

class MantaConnectionError(Exception):
  pass

def _check_env():
  """
  Make sure environmental variables are present.
  """
  if not MANTA_URL:
    raise MantaConnectionError(
      'You must set MANTA_URL as an environmental variable.'
    )

  if not MANTA_USER:
    raise MantaConnectionError(
      'You must set MANTA_USER as an environmental variable.'
    )

  if 'localhost' not in MANTA_URL:
    if not MANTA_KEY_ID:
      raise MantaConnectionError(
        'For a non-local client, you must set'
        'MANTA_KEY_ID as an environmental variable.'
      )  

def connect():
  """
  connect to manta 
  """
  _check_env()

  if 'localhost' in MANTA_URL:
    client = manta.MantaClient(MANTA_URL, MANTA_USER, internal=True)
  else:
    signer = manta.SSHAgentSigner(MANTA_KEY_ID)
    client = manta.MantaClient(MANTA_URL, MANTA_USER, MANTA_KEY_ID)

  return client

# HACK for now, should figure out how 
# to announce errors on init of various classes.
client = connect()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.