Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 27340200C17 for ; Fri, 27 Jan 2017 06:11:15 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 260DA160B50; Fri, 27 Jan 2017 05:11:15 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 46AB3160B4C for ; Fri, 27 Jan 2017 06:11:14 +0100 (CET) Received: (qmail 67810 invoked by uid 500); 27 Jan 2017 05:11:13 -0000 Mailing-List: contact commits-help@zeppelin.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zeppelin.apache.org Delivered-To: mailing list commits@zeppelin.apache.org Received: (qmail 67799 invoked by uid 99); 27 Jan 2017 05:11:13 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Jan 2017 05:11:13 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 33D1FDFA68; Fri, 27 Jan 2017 05:11:13 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: felixcheung@apache.org To: commits@zeppelin.apache.org Message-Id: <088ed7d1fa3142f2befc5436ab6da301@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: zeppelin git commit: [ZEPPELIN-1781] Failed to run the script 'test_zeppelin_pr.py' on Windows 10 Date: Fri, 27 Jan 2017 05:11:13 +0000 (UTC) archived-at: Fri, 27 Jan 2017 05:11:15 -0000 Repository: zeppelin Updated Branches: refs/heads/master 7486ce15a -> b1e06919f [ZEPPELIN-1781] Failed to run the script 'test_zeppelin_pr.py' on Windows 10 ### What is this PR for? Fix failure of script execution on Windows 10 ### What type of PR is it? [Bug Fix] ### Todos ### What is the Jira issue? [ZEPPELIN-1781](https://issues.apache.org/jira/browse/ZEPPELIN-1781) ### How should this be tested? Run 'test_zeppelin_pr.py' on Windows 10. ### 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: Myoungdo Park Closes #1742 from cuspymd/test-pr and squashes the following commits: c468212 [Myoungdo Park] Make it runnable on Python 2/3 eb4b567 [Myoungdo Park] Fix failure of script execution on Windows 10 Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/b1e06919 Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/b1e06919 Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/b1e06919 Branch: refs/heads/master Commit: b1e06919fada4240f5440430f2c27c02e4e5626a Parents: 7486ce1 Author: Myoungdo Park Authored: Wed Dec 14 02:17:09 2016 +0900 Committer: Felix Cheung Committed: Thu Jan 26 21:11:08 2017 -0800 ---------------------------------------------------------------------- dev/test_zeppelin_pr.py | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zeppelin/blob/b1e06919/dev/test_zeppelin_pr.py ---------------------------------------------------------------------- diff --git a/dev/test_zeppelin_pr.py b/dev/test_zeppelin_pr.py index 9b21b0e..22602d0 100755 --- a/dev/test_zeppelin_pr.py +++ b/dev/test_zeppelin_pr.py @@ -24,19 +24,25 @@ # then pr[#PR] branch will be created. # -import sys, os, subprocess -import json, urllib +from __future__ import print_function +import sys, os, subprocess, json, codecs + +if sys.version_info[0] == 2: + from urllib import urlopen +else: + from urllib.request import urlopen if len(sys.argv) == 1: - print "usage) " + sys.argv[0] + " [#PR]" - print " eg) " + sys.argv[0] + " 122" + print("usage) " + sys.argv[0] + " [#PR]") + print(" eg) " + sys.argv[0] + " 122") sys.exit(1) pr=sys.argv[1] githubApi="https://api.github.com/repos/apache/zeppelin" -prInfo = json.load(urllib.urlopen(githubApi + "/pulls/" + pr)) +reader = codecs.getreader("utf-8") +prInfo = json.load(reader(urlopen(githubApi + "/pulls/" + pr))) if "message" in prInfo and prInfo["message"] == "Not Found": sys.stderr.write("PullRequest #" + pr + " not found\n") sys.exit(1) @@ -44,6 +50,7 @@ if "message" in prInfo and prInfo["message"] == "Not Found": prUser=prInfo['user']['login'] prRepoUrl=prInfo['head']['repo']['clone_url'] prBranch=prInfo['head']['label'].replace(":", "/") +print(prBranch) # create local branch exitCode = os.system("git checkout -b pr" + pr) @@ -63,21 +70,21 @@ if exitCode != 0: sys.exit(1) -currentBranch = subprocess.check_output(["git rev-parse --abbrev-ref HEAD"], shell=True).rstrip() +currentBranch = subprocess.check_output("git rev-parse --abbrev-ref HEAD", shell=True).rstrip().decode("utf-8") -print "Merge branch " + prBranch + " into " + currentBranch +print("Merge branch " + prBranch + " into " + currentBranch) -rev = subprocess.check_output(["git rev-parse " + prBranch], shell=True).rstrip() -prAuthor = subprocess.check_output(["git --no-pager show -s --format='%an <%ae>' " + rev], shell=True).rstrip() -prAuthorDate = subprocess.check_output(["git --no-pager show -s --format='%ad' " + rev], shell=True).rstrip() +rev = subprocess.check_output("git rev-parse " + prBranch, shell=True).rstrip().decode("utf-8") +prAuthor = subprocess.check_output("git --no-pager show -s --format=\"%an <%ae>\" " + rev, shell=True).rstrip().decode("utf-8") +prAuthorDate = subprocess.check_output("git --no-pager show -s --format=\"%ad\" " + rev, shell=True).rstrip().decode("utf-8") prTitle = prInfo['title'] prBody = prInfo['body'] -commitList = subprocess.check_output(["git log --pretty=format:'%h' " + currentBranch + ".." + prBranch], shell=True).rstrip() +commitList = subprocess.check_output("git log --pretty=format:\"%h\" " + currentBranch + ".." + prBranch, shell=True).rstrip().decode("utf-8") authorList = [] for commitHash in commitList.split("\n"): - a = subprocess.check_output(["git show -s --pretty=format:'%an <%ae>' "+commitHash], shell=True).rstrip() + a = subprocess.check_output("git show -s --pretty=format:\"%an <%ae>\" "+commitHash, shell=True).rstrip().decode("utf-8") if a not in authorList: authorList.append(a) @@ -85,20 +92,20 @@ commitMsg = prTitle + "\n" if prBody : commitMsg += prBody + "\n\n" for author in authorList: - commitMsg += "Author: " + author+"\n" + commitMsg += "Author: " + author +"\n" commitMsg += "\n" commitMsg += "Closes #" + pr + " from " + prBranch + " and squashes the following commits:\n\n" -commitMsg += subprocess.check_output(["git log --pretty=format:'%h [%an] %s' " + currentBranch + ".." + prBranch], shell=True).rstrip() +commitMsg += subprocess.check_output("git log --pretty=format:\"%h [%an] %s\" " + currentBranch + ".." + prBranch, shell=True).rstrip().decode("utf-8") exitCode = os.system("git merge --no-commit --squash " + prBranch) if exitCode != 0: sys.stderr.write("Can not merge\n") sys.exit(1) -exitCode = os.system('git commit -a --author "' + prAuthor + '" --date "' + prAuthorDate + '" -m"' + commitMsg.encode('utf-8') + '"') +exitCode = os.system('git commit -a --author "' + prAuthor + '" --date "' + prAuthorDate + '" -m"' + commitMsg + '"') if exitCode != 0: sys.stderr.write("Commit failed\n") sys.exit(1) os.system("git remote remove " + prUser) -print "Branch " + prBranch + " is merged into " + currentBranch +print("Branch " + prBranch + " is merged into " + currentBranch)