Skip to content
This repository has been archived by the owner on Jul 20, 2020. It is now read-only.

Bug Fixes on Github Extension #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions build/extension_init.sh
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |

--------------------------------------------------------------------------------------------------------------------

Expand Down
12 changes: 6 additions & 6 deletions github/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion github/static/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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 {
Expand Down
9 changes: 5 additions & 4 deletions github/static/githubcommit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = $("<form id='option'/>")
.append("<label class=\"radio-inline\"><input type=\"radio\" name=\"optradio\" value='single' checked>Commit this notebook only</label>\n" +
"<label class=\"radio-inline\"><input type=\"radio\" name=\"optradio\" value='multiple' >Commit all notebooks in this folder</label>");
Expand All @@ -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; }
Expand Down
6 changes: 1 addition & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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,
Expand Down