Commit 4c5b8c3b authored by Roland Haas's avatar Roland Haas
Browse files

add option to suppress user input and info output

parent 7238fc60
......@@ -32,7 +32,10 @@ class GlobusTransferHelper:
# access token it lets the script act on the user's behalf
CLIENT_ID = 'c87acef9-2bac-4743-90e8-2ae9e999ff29'
# TODO add globus magic strings as constants
def __init__(self):
def __init__(self, interactive=True):
"""interactive - some screen output, ask for input if needed"""
self.interactive = interactive
REDIRECT_URI = 'https://auth.globus.org/v2/web/auth-code'
SCOPES = 'openid email profile ' \
'urn:globus:auth:scope:transfer.api.globus.org:all'
......@@ -44,7 +47,10 @@ class GlobusTransferHelper:
tokens = self.load_tokens_from_file(TOKEN_FILE)
except:
# if we still need to get tokens, start the Native App authentication process
tokens = self.do_native_app_authentication(self.CLIENT_ID, REDIRECT_URI, SCOPES)
if interactive:
tokens = self.do_native_app_authentication(self.CLIENT_ID, REDIRECT_URI, SCOPES)
else:
raise
try:
self.save_tokens_to_file(TOKEN_FILE, tokens)
except:
......@@ -131,8 +137,8 @@ class GlobusTransferHelper:
None
"""
while not self.tclient.task_wait(result["task_id"], timeout=self.TIMEOUT):
print("Waiting on {0} to complete"
.format(result["task_id"]))
if interactive:
print("Waiting on {0} to complete".format(result["task_id"]))
def delete(self, endpoint, paths, recursive = False, synchronous = True,
mylabel = None):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment