This is an automated email from the ASF dual-hosted git repository. fgreg pushed a commit to branch SDAP-125 in repository https://gitbox.apache.org/repos/asf/incubator-sdap-nexus.git
commit 851d067a7e584cdf2b3e0cdd159032d383bb7b5e Author: Frank Greguska <[email protected]> AuthorDate: Tue Jul 17 16:27:19 2018 -0700 Remove duplicate global variable and function. --- client/nexuscli/nexuscli_ow.py | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/client/nexuscli/nexuscli_ow.py b/client/nexuscli/nexuscli_ow.py index feae3e2..4cb7bf6 100644 --- a/client/nexuscli/nexuscli_ow.py +++ b/client/nexuscli/nexuscli_ow.py @@ -38,40 +38,27 @@ Usage: valid pyspark code. For pyspark code the variable sc may be used to access the SparkContext, but it should not create the SparkContext. """ -import requests import ast -target = 'http://localhost:8084' - -session = requests.session() +import requests +from nexuscli import nexuscli -def set_target(url, use_session=True): - """ - Set the URL for the NEXUS webapp endpoint. - - __url__ URL for NEXUS webapp endpoint - __return__ None - """ - global target - target = url +session = requests.session() - if not use_session: - global session - session = requests +set_target = nexuscli.set_target def run_file(fname): files = {'file': open(fname, 'rb')} - response = session.post(target+'/run_file', files=files) + response = session.post(nexuscli.target + '/run_file', files=files) print(response.text) return response.text - + def run_str(code): - response = requests.post(target+'/run_str', data=code) + response = requests.post(nexuscli.target + '/run_str', data=code) ans = ast.literal_eval(response.text)['text/plain'] for line in ans: print(line, end=" ") return ans -
