Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install fails bc of configuation requirements #1

Open
abelsonlive opened this issue May 4, 2014 · 0 comments
Open

Install fails bc of configuation requirements #1

abelsonlive opened this issue May 4, 2014 · 0 comments

Comments

@abelsonlive
Copy link

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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant