From c551d48e3bdb2843dd46d052c00267bb53a26176 Mon Sep 17 00:00:00 2001 From: Weijun Qian Date: Thu, 6 Dec 2018 15:27:30 -0800 Subject: [PATCH] Bug Fixes on Github Extension --- build/extension_init.sh | 7 +++---- docs/index.md | 4 ++-- github/github.py | 12 ++++++------ github/static/github.js | 6 +++++- github/static/githubcommit.js | 9 +++++---- setup.py | 6 +----- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/build/extension_init.sh b/build/extension_init.sh index 14b0196..e814d04 100644 --- a/build/extension_init.sh +++ b/build/extension_init.sh @@ -1,8 +1,7 @@ #!/bin/sh -jupyter nbextension install scheduler --user --py -jupyter nbextension enable scheduler --user --py -jupyter serverextension enable scheduler --py --user - jupyter nbextension install github --user --py jupyter nbextension enable github --user --py jupyter serverextension enable github --py --user +git config --global user.email $githubemail +git config --global user.name $githubname +git-nbmergedriver config --enable --global diff --git a/docs/index.md b/docs/index.md index ae53e51..1af2198 100644 --- a/docs/index.md +++ b/docs/index.md @@ -20,8 +20,8 @@ PPExtensions is a suite of ipython and jupyter extensions built to improve user | Feature | Available | State | |---------------------- | ------------- | -------------| | PPMagics | Available | Beta | -| Scheduling Notebooks | Coming soon | Coming soon | -| Github Integration | Coming soon | Coming soon | +| Scheduling Notebooks | Available | Beta | +| Github Integration | Available | Beta | -------------------------------------------------------------------------------------------------------------------- diff --git a/github/github.py b/github/github.py index 801a922..76bfb8b 100644 --- a/github/github.py +++ b/github/github.py @@ -10,7 +10,7 @@ GITHUB_URL_PREFIX = "https://github.com/" GITHUB_API_PREFIX = "https://api.github.com" -GITHUB_TOKEN = os.getenv("githubtoken","") +GITHUB_TOKEN = os.getenv("githubtoken", "") NOTEBOOK_STARTUP_PATH = os.getcwd() + "/" LOCAL_REPO_FOLDER = "Sharing" LOCAL_REPO_PREFIX = NOTEBOOK_STARTUP_PATH + LOCAL_REPO_FOLDER @@ -47,7 +47,7 @@ def git_commit(self, from_path, to_path, file_name, repo_instance, commit_messag self.error_handler(str(e)) git_instance = repo_instance.git if not os.path.isdir(to_path): - git_instance.add(file_name) + git_instance.add(to_path) else: git_instance.add("--a") git_instance.commit("-m", commit_message) @@ -187,17 +187,17 @@ class PrivateGitCommitHandler(PrivateGitHandler): """ def post(self): - repo_name = unquote(self.get_argument("repo")) - file_name = unquote(self.get_argument("filename")) + repo = unquote(self.get_argument("repo")) + file = unquote(self.get_argument("file")) option = self.get_argument("option") commit_message = "Commit from PayPal Notebook" - local_repo_path = NOTEBOOK_STARTUP_PATH + repo_name + local_repo_path = LOCAL_REPO_PREFIX + "/" + repo try: repo_instance = Repo(local_repo_path) except exc.InvalidGitRepositoryError as e: self.error_handler(str(e)) try: - self.git_commit_inside(file_name, repo_instance, commit_message, option) + self.git_commit_inside(file, repo_instance, commit_message, option) self.finish("Commit Success!") except GitCommandError as e: if e.status == 1: diff --git a/github/static/github.js b/github/static/github.js index 8e3af7d..de1831b 100644 --- a/github/static/github.js +++ b/github/static/github.js @@ -38,6 +38,9 @@ define(["base/js/namespace", "base/js/dialog", "tree/js/notebooklist", "base/js/ method: "GET", data: {"filepath": selected.path}, success: function(res) { + if (!selected.path.startsWith("Sharing")){ + sessionStorage.setItem(url, res); + } res = JSON.parse(res); for (var rp in res) { repo.append(new Option(rp, rp)); @@ -56,7 +59,8 @@ define(["base/js/namespace", "base/js/dialog", "tree/js/notebooklist", "base/js/ }, }; var url = utils.url_path_join(that.base_url, "/github/private_github_get_repo"); - if (sessionStorage.getItem(url) != null) { + + if (sessionStorage.getItem(url) != null && !selected.path.startsWith("Sharing")) { var res = JSON.parse(sessionStorage.getItem(url)); initializeDropdown(res); } else { diff --git a/github/static/githubcommit.js b/github/static/githubcommit.js index 75c468b..898d623 100644 --- a/github/static/githubcommit.js +++ b/github/static/githubcommit.js @@ -5,10 +5,11 @@ define(["base/js/namespace", "base/js/dialog", "base/js/utils", "jquery"], funct icon: "fa-github", help_index: "", handler: function (env) { - var re = /^\/notebooks(.*?)$/; + var re = /^\/notebooks\/Sharing\/(.*?)$/; var filepath = window.location.pathname.match(re)[1]; - var repo = filepath.substring(1, filepath.lastIndexOf("/")); - var filename = filepath.substring(filepath.lastIndexOf("/") + 1, filepath.length); + var comp = filepath.split("/"); + var repo = [comp[0],comp[1]].join("/") + var file = comp.slice(2,).join("/"); var dialog_body = $("
") .append("\n" + ""); @@ -22,7 +23,7 @@ define(["base/js/namespace", "base/js/dialog", "base/js/utils", "jquery"], funct click: function () { var payload = { "repo": repo, - "filename": filename, + "file": file, "option": $("input[name=optradio]:checked", "#option").val() }; if (repo === "/"){ alert("Please commit inside local repo!"); return; } diff --git a/setup.py b/setup.py index 91bb71f..a32f228 100644 --- a/setup.py +++ b/setup.py @@ -18,8 +18,6 @@ install_requires = [ 'ipython>=1.0', - 'qgrid', - 'impyla==0.13.8', 'hdfs3', 'teradata==15.10.0.20', 'protobuf==3.5.2.post1', @@ -32,11 +30,9 @@ 'astor', 'pandas==0.22.0', 'autovizwidget', - 'thrift-sasl==0.2.1', - 'apache-airflow==1.8.2', 'nbdime', 'gitpython', - 'mysql-connector-python-rf' + 'matplotlib' ] setup(name=NAME,