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

Sandbox or Production or custom host #20

Merged
merged 1 commit into from
Sep 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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