/boto-2.5.2/tests/mturk/_init_environment.py

# · Python · 28 lines · 20 code · 5 blank · 3 comment · 3 complexity · 39e8e5134693705108de3168f8a603ef MD5 · raw file

  1. import os
  2. import functools
  3. live_connection = False
  4. mturk_host = 'mechanicalturk.sandbox.amazonaws.com'
  5. external_url = 'http://www.example.com/'
  6. SetHostMTurkConnection = None
  7. def config_environment():
  8. global SetHostMTurkConnection
  9. try:
  10. local = os.path.join(os.path.dirname(__file__), 'local.py')
  11. execfile(local)
  12. except:
  13. pass
  14. if live_connection:
  15. #TODO: you must set the auth credentials to something valid
  16. from boto.mturk.connection import MTurkConnection
  17. else:
  18. # Here the credentials must be set, but it doesn't matter what
  19. # they're set to.
  20. os.environ.setdefault('AWS_ACCESS_KEY_ID', 'foo')
  21. os.environ.setdefault('AWS_SECRET_ACCESS_KEY', 'bar')
  22. from mocks import MTurkConnection
  23. SetHostMTurkConnection = functools.partial(MTurkConnection, host=mturk_host)