From 6dbce7dd42eedf3fff1db140b1fbe821bb69cdb9 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 3 Mar 2017 14:41:57 -0500 Subject: [PATCH] make validate work with python 3 Update the check_output() calls used by the validate command so the results are decoded before being treated as strings. Change-Id: I099ff997f69743d2958fc5581292aacebd7f5d37 Signed-off-by: Doug Hellmann --- openstack_releases/gitutils.py | 18 +++++++++--------- openstack_releases/pythonutils.py | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/openstack_releases/gitutils.py b/openstack_releases/gitutils.py index 38fcedc496..5c7198dd48 100644 --- a/openstack_releases/gitutils.py +++ b/openstack_releases/gitutils.py @@ -31,7 +31,7 @@ def find_modified_deliverable_files(): "Return a list of files modified by the most recent commit." results = subprocess.check_output( ['git', 'diff', '--name-only', '--pretty=format:', 'HEAD^'] - ) + ).decode('utf-8') filenames = [ l.strip() for l in results.splitlines() @@ -105,7 +105,7 @@ def sha_for_tag(workdir, repo, version): ['git', 'log', str(version), '-n', '1', '--pretty=format:%H'], cwd=os.path.join(workdir, repo), stderr=subprocess.STDOUT, - ) + ).decode('utf-8') actual_sha = actual_sha.strip() except subprocess.CalledProcessError as e: print('ERROR getting SHA for tag %r: %s [%s]' % @@ -128,7 +128,7 @@ def check_branch_sha(workdir, repo, series, master, sha): output = subprocess.check_output( ['git', 'branch', '-a', '--contains', sha], cwd=os.path.join(workdir, repo), - ).strip() + ).decode('utf-8').strip() for branch in output.split(): if branch == remote_match: return True @@ -145,7 +145,7 @@ def check_ancestry(workdir, repo, old_version, sha): ['git', 'log', '--oneline', '--ancestry-path', '%s..%s' % (old_version, sha)], cwd=os.path.join(workdir, repo), - ).strip() + ).decode('utf-8').strip() return bool(ancestors) except subprocess.CalledProcessError as e: print('ERROR checking ancestry: %s [%s]' % (e, e.output.strip())) @@ -161,7 +161,7 @@ def get_latest_tag(workdir, repo, sha=None): cmd, cwd=os.path.join(workdir, repo), stderr=subprocess.STDOUT, - ).strip() + ).decode('utf-8').strip() except subprocess.CalledProcessError as e: print('WARNING failed to retrieve latest tag: %s [%s]' % (e, e.output.strip())) @@ -174,7 +174,7 @@ def get_branches(workdir, repo): ['git', 'branch', '-a'], cwd=os.path.join(workdir, repo), stderr=subprocess.STDOUT, - ).strip() + ).decode('utf-8').strip() # Example output: # * (no branch) # master @@ -207,7 +207,7 @@ def branches_containing(workdir, repo, ref): ['git', 'branch', '-r', '--contains', ref], cwd=os.path.join(workdir, repo), stderr=subprocess.STDOUT, - ).strip() + ).decode('utf-8').strip() # Example output: # origin/stable/ocata results = [] @@ -238,7 +238,7 @@ def get_branch_base(workdir, repo, branch): cmd, cwd=os.path.join(workdir, repo), stderr=subprocess.STDOUT, - ).strip() + ).decode('utf-8').strip() except subprocess.CalledProcessError as e: print('WARNING failed to retrieve branch base: %s [%s]' % (e, e.output.strip())) @@ -255,7 +255,7 @@ def get_branch_base(workdir, repo, branch): cmd, cwd=os.path.join(workdir, repo), stderr=subprocess.STDOUT, - ).strip() + ).decode('utf-8').strip() except subprocess.CalledProcessError as e: print('WARNING failed to retrieve branch base: %s [%s]' % (e, e.output.strip())) diff --git a/openstack_releases/pythonutils.py b/openstack_releases/pythonutils.py index 236a2f528a..4f5666ae65 100644 --- a/openstack_releases/pythonutils.py +++ b/openstack_releases/pythonutils.py @@ -42,7 +42,7 @@ def get_sdist_name(workdir, repo): subprocess.check_output(cmd, cwd=dest) # Run it again to get a clean version of the name. print('Running: %s in %s' % (' '.join(cmd), dest)) - out = subprocess.check_output(cmd, cwd=dest) + out = subprocess.check_output(cmd, cwd=dest).decode('utf-8') print('Results: %s' % (out,)) name = out.splitlines()[-1].strip() return name