Skip to content

Commit

Permalink
Merge pull request #20 from crowdresearch/api
Browse files Browse the repository at this point in the history
Sandbox or Production or custom host
  • Loading branch information
shirishgoyal committed Sep 14, 2016
2 parents 39c40db + 0272dcf commit 5ca8964
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions daemo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
More information is available at http://daemo-api-client.readthedocs.io/en/latest/
"""

from .constants import *
from .client import DaemoClient
14 changes: 11 additions & 3 deletions daemo/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion daemo/constants.py
Original file line number Diff line number Diff line change
@@ -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/"
Expand Down

0 comments on commit 5ca8964

Please sign in to comment.