Repository: incubator-zeppelin Updated Branches: refs/heads/master 8febe795b -> c54b8821f
ZEPPELIN-314 + ZEPPELIN-562 ] support pyspark completion for python3 ### What is this PR for? pyspark- completion function has been modified to work in python3 environment. ### What type of PR is it? bug-fix, enhanced. ### Todos * [x] - Change the code python3 support. ### Is there a relevant Jira issue? https://issues.apache.org/jira/browse/ZEPPELIN-314 https://issues.apache.org/jira/browse/ZEPPELIN-562 (comment) ### How should this be tested? pyspark - in python3 environment. ex) Zeppelin interpreter page -> spark property -> zeppelin.pyspark.python = /usr/bin/python3 Use completion function (Shift + control + space). ### Screenshots (if appropriate)  ### Questions: * Does the licenses files need update? no * Is there breaking changes for older versions? no * Does this needs documentation? no Author: Estail7s <[email protected]> Closes #601 from cloverhearts/ZEPPELIN-314-pyspark3-completion and squashes the following commits: aaee596 [Estail7s] Support python3 for pyspark completion f2821e1 [Estail7s] Pyspark - support python 3 Project: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/commit/c54b8821 Tree: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/tree/c54b8821 Diff: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/diff/c54b8821 Branch: refs/heads/master Commit: c54b8821fca075ca828457d5aa85a8834cb6893d Parents: 8febe79 Author: Estail7s <[email protected]> Authored: Tue Jan 5 14:38:43 2016 -0800 Committer: Lee moon soo <[email protected]> Committed: Thu Jan 7 13:59:51 2016 -0800 ---------------------------------------------------------------------- spark/src/main/resources/python/zeppelin_pyspark.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/c54b8821/spark/src/main/resources/python/zeppelin_pyspark.py ---------------------------------------------------------------------- diff --git a/spark/src/main/resources/python/zeppelin_pyspark.py b/spark/src/main/resources/python/zeppelin_pyspark.py index 7ab0be9..62f0a82 100644 --- a/spark/src/main/resources/python/zeppelin_pyspark.py +++ b/spark/src/main/resources/python/zeppelin_pyspark.py @@ -111,7 +111,7 @@ class PySparkCompletion: def getGlobalCompletion(self): objectDefList = [] try: - for completionItem in list(globals().iterkeys()): + for completionItem in list(globals().keys()): objectDefList.append(completionItem) except: return None @@ -119,18 +119,20 @@ class PySparkCompletion: return objectDefList def getMethodCompletion(self, text_value): - objectDefList = [] + execResult = locals() + if text_value == None: + return None completion_target = text_value try: if len(completion_target) <= 0: return None if text_value[-1] == ".": completion_target = text_value[:-1] - exec("%s = %s(%s)" % ("objectDefList", "dir", completion_target)) + exec("{} = dir({})".format("objectDefList", completion_target), globals(), execResult) except: return None else: - return objectDefList + return list(execResult['objectDefList']) def getCompletion(self, text_value): @@ -147,9 +149,9 @@ class PySparkCompletion: for completionItem in list(objectCompletionList): completionList.add(completionItem) if len(completionList) <= 0: - print "" + print("") else: - print json.dumps(filter(lambda x : not re.match("^__.*", x), list(completionList))) + print(json.dumps(list(filter(lambda x : not re.match("^__.*", x), list(completionList))))) output = Logger()
