Handle cleanup if there's a failure during generation of release notes.

This commit is contained in:
Ewen Cheslack-Postava 2017-05-03 10:29:48 -07:00
parent fa58401279
commit 1a6947af34
1 changed files with 17 additions and 7 deletions

View File

@ -68,6 +68,12 @@ def fail(msg):
print(msg)
sys.exit(1)
def print_output(output):
if output is None or len(output) == 0:
return
for line in output.split('\n'):
print(">", line)
def cmd(action, cmd, *args, **kwargs):
if isinstance(cmd, basestring) and not kwargs.get("shell", False):
cmd = cmd.split()
@ -80,12 +86,6 @@ def cmd(action, cmd, *args, **kwargs):
stdin.seek(0)
kwargs["stdin"] = stdin
def print_output(output):
if len(output) == 0:
return
for line in output.split('\n'):
print(">", line)
print(action, cmd, stdin_log)
try:
output = subprocess.check_output(cmd, *args, stderr=subprocess.STDOUT, **kwargs)
@ -283,7 +283,17 @@ cmd("Verifying the correct year in NOTICE", "grep %s NOTICE" % current_year, cwd
with open(os.path.join(artifacts_dir, "RELEASE_NOTES.html"), 'w') as f:
print("Generating release notes")
subprocess.check_call(["./release_notes.py", release_version], stdout=f)
try:
subprocess.check_call(["./release_notes.py", release_version], stdout=f)
except subprocess.CalledProcessError as e:
print_output(e.output)
print("*************************************************")
print("*** First command failure occurred here. ***")
print("*** Will now try to clean up working state. ***")
print("*************************************************")
fail("")
params = { 'release_version': release_version,
'rc_tag': rc_tag,