switch from Popen to check_output in release notes tools
The copy of release_notes.py imported from the release-tools repo was modified to use Popen instead of oslo.concurrency. However, that change was made incorrectly, and an invalid exception was being caught. When the commands work fine, this doesn't present a problem. When the commands fail, it breaks error handling. Replace all of the local logic with check_call(), the function used elsewhere in this repo for running background commands. Update users of run_cmd() in release_notes.py to only expect to receive stdout as a response. Change-Id: I291a077ed613c3e4ad56b85c81945c15a6301c17 Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
parent
0542c71fdb
commit
3fc5805761
@ -226,18 +226,8 @@ def expand_template(contents, params):
|
||||
|
||||
|
||||
def run_cmd(cmd, cwd=None, encoding='utf-8'):
|
||||
# Created since currently the 'processutils' function doesn't take a
|
||||
# working directory, which we need in this example due to the different
|
||||
# working directories we run programs in...
|
||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||
cwd=cwd)
|
||||
stdout, stderr = p.communicate()
|
||||
if p.returncode != 0:
|
||||
raise subprocess.ProcessExecutionError(stdout=stdout,
|
||||
stderr=stderr,
|
||||
exit_code=p.returncode,
|
||||
cmd=cmd)
|
||||
return stdout.decode(encoding), stderr.decode(encoding)
|
||||
stdout = subprocess.check_output(cmd, cwd=cwd)
|
||||
return stdout.decode(encoding)
|
||||
|
||||
|
||||
def is_skippable_commit(skip_requirement_merges, line):
|
||||
@ -305,7 +295,7 @@ def generate_release_notes(repo, repo_path,
|
||||
else:
|
||||
format = "--oneline"
|
||||
cmd = ["git", "log", "--no-color", format, "--no-merges", git_range]
|
||||
stdout, stderr = run_cmd(cmd, cwd=repo_path)
|
||||
stdout = run_cmd(cmd, cwd=repo_path)
|
||||
changes = []
|
||||
for commit_line in stdout.splitlines():
|
||||
commit_line = commit_line.strip()
|
||||
@ -322,13 +312,13 @@ def generate_release_notes(repo, repo_path,
|
||||
if requirement_files:
|
||||
cmd = ['git', 'diff', '-U0', '--no-color', git_range]
|
||||
cmd.extend(requirement_files)
|
||||
stdout, stderr = run_cmd(cmd, cwd=repo_path)
|
||||
stdout = run_cmd(cmd, cwd=repo_path)
|
||||
requirement_changes = [line.strip()
|
||||
for line in stdout.splitlines() if line.strip()]
|
||||
|
||||
# Get statistics about the range given...
|
||||
cmd = ['git', 'diff', '--stat', '--no-color', git_range]
|
||||
stdout, stderr = run_cmd(cmd, cwd=repo_path)
|
||||
stdout = run_cmd(cmd, cwd=repo_path)
|
||||
diff_stats = []
|
||||
for line in stdout.splitlines():
|
||||
line = line.strip()
|
||||
|
Loading…
Reference in New Issue
Block a user