PageRenderTime 19ms CodeModel.GetById 15ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

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

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