diff --git a/daemo/__init__.py b/daemo/__init__.py index 010cbd7..0e5192c 100644 --- a/daemo/__init__.py +++ b/daemo/__init__.py @@ -3,4 +3,5 @@ More information is available at http://daemo-api-client.readthedocs.io/en/latest/ """ +from .constants import * from .client import DaemoClient diff --git a/daemo/client.py b/daemo/client.py index 803be95..789681a 100644 --- a/daemo/client.py +++ b/daemo/client.py @@ -37,11 +37,12 @@ class DaemoClient: :param multi_threading: False by default, bool value to enable multi-threaded response handling :param host: daemo server to connect to - uses a default server if not defined :param is_secure: boolean flag to control if connection happen via secure mode or not + :param is_sandbox: boolean flag to control if tasks will be posted to sandbox instead of production system of Daemo """ - def __init__(self, credentials_path='credentials.json', rerun_key=None, multi_threading=False, host=HOST, - is_secure=True): + def __init__(self, credentials_path='credentials.json', rerun_key=None, multi_threading=False, host=None, + is_secure=True, is_sandbox=False): log.info(msg="initializing client...") self.check_dependency(credentials_path is not None and len(credentials_path) > 0, Error.required("credentials_path")) @@ -53,7 +54,14 @@ def __init__(self, credentials_path='credentials.json', rerun_key=None, multi_th self.http_proto = "https://" self.websock_proto = "wss://" - self.host = host + if is_sandbox: + self.host = SANDBOX + else: + self.host = PRODUCTION + + if host is not None: + self.host = host + self.credentials_path = credentials_path self.rerun_key = rerun_key self.multi_threading = multi_threading diff --git a/daemo/constants.py b/daemo/constants.py index 7fc5d8a..4976b73 100644 --- a/daemo/constants.py +++ b/daemo/constants.py @@ -1,6 +1,6 @@ __version__ = "1.0.2" -HOST = "daemo.stanford.edu" +PRODUCTION = "daemo.stanford.edu" SANDBOX = "daemo-test.herokuapp.com" WS_BOT_SUBSCRIBE_URL = "/ws/bot?subscribe-user" OAUTH_TOKEN_URL = "/api/oauth2-ng/token/"