This is an automated email from the ASF dual-hosted git repository.
fgreg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-sdap-nexus.git
The following commit(s) were added to refs/heads/master by this push:
new f42107e SDAP-125 Conflict with global variable in client (#24)
f42107e is described below
commit f42107eb9ffd630415f5418f4acf0265a190fbaa
Author: fgreg <[email protected]>
AuthorDate: Tue Jul 17 16:47:10 2018 -0700
SDAP-125 Conflict with global variable in client (#24)
* Remove duplicate global variable and function.
* Add log statement
---
client/nexuscli/nexuscli.py | 1 +
client/nexuscli/nexuscli_ow.py | 27 +++++++--------------------
2 files changed, 8 insertions(+), 20 deletions(-)
diff --git a/client/nexuscli/nexuscli.py b/client/nexuscli/nexuscli.py
index 1fe024f..c431f46 100644
--- a/client/nexuscli/nexuscli.py
+++ b/client/nexuscli/nexuscli.py
@@ -68,6 +68,7 @@ def set_target(url, use_session=True):
"""
global target
target = url
+ print("Target set to {}".format(target))
if not use_session:
global session
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
-