From b9efe625ea57c443c1b907691ef4a579d1d32b6c Mon Sep 17 00:00:00 2001 From: mrstanwell Date: Tue, 22 Jan 2019 16:30:50 -0600 Subject: [PATCH 1/3] Remove piping and cmd substitution call in Popen cmd. The gen_create_branch_changes() function was building a Popen command that used shell pipes and cmd substitution, however this was causing the script to fail because Popen doesn't interpret the pipes and cmd substitution correctly. Instead, I broke the command up into separate Popen calls and piped them together. --- master/contrib/git_buildbot.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/master/contrib/git_buildbot.py b/master/contrib/git_buildbot.py index 3687ece..748d921 100755 --- a/master/contrib/git_buildbot.py +++ b/master/contrib/git_buildbot.py @@ -221,15 +221,21 @@ def gen_create_branch_changes(newrev, refname, branch): logging.info("Branch `%s' created", branch) - f = subprocess.Popen(shlex.split("git rev-parse --not --branches" - + "| grep -v $(git rev-parse %s)" % refname - + - "| git rev-list --reverse --pretty=oneline --stdin %s" % newrev), - stdout=subprocess.PIPE) - - gen_changes(f, branch) - - status = f.close() + p = subprocess.Popen(shlex.split("git rev-parse %s" % refname), stdout=subprocess.PIPE) + branchref = p.communicate()[0].strip().decode(encoding) + f = subprocess.Popen(shlex.split("git rev-parse --not --branches"), stdout=subprocess.PIPE) + f2 = subprocess.Popen(shlex.split("grep -v %s" % branchref), + stdin=f.stdout, + stdout=subprocess.PIPE) + f3 = subprocess.Popen( + shlex.split("git rev-list --reverse --pretty=oneline --stdin %s" % newrev), + stdin=f2.stdout, + stdout=subprocess.PIPE + ) + + gen_changes(f3, branch) + + status = f3.returncode if status: logging.warning("git rev-list exited with status %d", status) From 2f2d25f6b631efd51b45ecd84f3df1b4390fc5d4 Mon Sep 17 00:00:00 2001 From: mrstanwell Date: Tue, 22 Jan 2019 17:02:36 -0600 Subject: [PATCH 2/3] Seems like Popen.returncode should be checked here for status. --- master/contrib/git_buildbot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/master/contrib/git_buildbot.py b/master/contrib/git_buildbot.py index 748d921..9c59108 100755 --- a/master/contrib/git_buildbot.py +++ b/master/contrib/git_buildbot.py @@ -249,7 +249,7 @@ def gen_create_tag_changes(newrev, refname, tag): f = subprocess.Popen(shlex.split("git log -n 1 --pretty=oneline %s" % newrev), stdout=subprocess.PIPE) gen_changes(f, tag) - status = f.close() + status = f.returncode if status: logging.warning("git log exited with status %d", status) @@ -292,7 +292,7 @@ def gen_update_branch_changes(oldrev, newrev, refname, branch): logging.debug(" Rewound file: %s", file) files.append(text_type(file)) - status = f.terminate() + status = f.returncode if status: logging.warning("git diff exited with status %d", status) From 60fc63ffd088c942e85ec3276d241d6a10b50ee2 Mon Sep 17 00:00:00 2001 From: mrstanwell Date: Fri, 29 Mar 2019 15:30:00 -0500 Subject: [PATCH 3/3] Replace calls to Popen.terminate() and .returncode with .wait(). --- master/contrib/git_buildbot.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/master/contrib/git_buildbot.py b/master/contrib/git_buildbot.py index 9c59108..2501ce9 100755 --- a/master/contrib/git_buildbot.py +++ b/master/contrib/git_buildbot.py @@ -177,7 +177,7 @@ def grab_commit_info(c, rev): c['comments'] = ''.join(comments) c['files'] = files - status = f.terminate() + status = f.wait() if status: logging.warning("git show exited with status %d", status) @@ -235,7 +235,7 @@ def gen_create_branch_changes(newrev, refname, branch): gen_changes(f3, branch) - status = f3.returncode + status = f3.wait() if status: logging.warning("git rev-list exited with status %d", status) @@ -249,7 +249,7 @@ def gen_create_tag_changes(newrev, refname, tag): f = subprocess.Popen(shlex.split("git log -n 1 --pretty=oneline %s" % newrev), stdout=subprocess.PIPE) gen_changes(f, tag) - status = f.returncode + status = f.wait() if status: logging.warning("git log exited with status %d", status) @@ -292,7 +292,7 @@ def gen_update_branch_changes(oldrev, newrev, refname, branch): logging.debug(" Rewound file: %s", file) files.append(text_type(file)) - status = f.returncode + status = f.wait() if status: logging.warning("git diff exited with status %d", status) @@ -324,7 +324,7 @@ def gen_update_branch_changes(oldrev, newrev, refname, branch): stdout=subprocess.PIPE) gen_changes(f, branch) - status = f.terminate() + status = f.wait() if status: logging.warning("git rev-list exited with status %d", status)