From 9d733a9ded25e89e381e4d0483d776eb9fc9b5ed Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Sat, 11 Apr 2020 09:48:49 -0500 Subject: [PATCH] Decode utf-8 from subprocess.Popen We use subprocess.Popen directly in these scripts rather than run_command. We need to decode the output so that we get strings back and not bytes. Change-Id: Ie967ceac77ecb898cab24827644b981eed22e141 --- jeepyb/cmd/notify_impact.py | 3 ++- jeepyb/cmd/update_blueprint.py | 9 ++++++--- jeepyb/cmd/update_bug.py | 3 ++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/jeepyb/cmd/notify_impact.py b/jeepyb/cmd/notify_impact.py index 1cc76c9..5b402f5 100644 --- a/jeepyb/cmd/notify_impact.py +++ b/jeepyb/cmd/notify_impact.py @@ -244,7 +244,8 @@ def extract_git_log(args): cmd = ['git', '--git-dir=' + GERRIT_GIT_DIR + '/' + args.project + '.git', 'log', '--no-merges', args.commit + '^1..' + args.commit] - return subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0] + return subprocess.Popen( + cmd, stdout=subprocess.PIPE).communicate()[0].decode('utf-8') def main(): diff --git a/jeepyb/cmd/update_blueprint.py b/jeepyb/cmd/update_blueprint.py index 0b1e44c..22efa84 100644 --- a/jeepyb/cmd/update_blueprint.py +++ b/jeepyb/cmd/update_blueprint.py @@ -111,9 +111,12 @@ def find_specs(launchpad, dbconn, args): git_dir_arg = '--git-dir={base_dir}/{project}.git'.format( base_dir=GERRIT_GIT_DIR, project=args.project) - git_log = subprocess.Popen(['git', git_dir_arg, 'log', '--no-merges', - args.commit + '^1..' + args.commit], - stdout=subprocess.PIPE).communicate()[0] + git_log = subprocess.Popen( + [ + 'git', git_dir_arg, 'log', '--no-merges', + args.commit + '^1..' + args.commit + ], + stdout=subprocess.PIPE).communicate()[0].decode('utf-8') change = args.change if '~' in change: diff --git a/jeepyb/cmd/update_bug.py b/jeepyb/cmd/update_bug.py index 0278aaa..64fa536 100644 --- a/jeepyb/cmd/update_bug.py +++ b/jeepyb/cmd/update_bug.py @@ -335,7 +335,8 @@ def extract_git_log(args): cmd = ['git', '--git-dir=' + GERRIT_GIT_DIR + '/' + args.project + '.git', 'log', '--no-merges', args.commit + '^1..' + args.commit] - return subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0] + return subprocess.Popen( + cmd, stdout=subprocess.PIPE).communicate()[0].decode('utf-8') def main():