Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4e3f275

Browse files
committed
Improve diagnostic output when an external command returns a non-zero exit
code, showing the transcript for that command. This closes SF bug #129740.
1 parent f36fb69 commit 4e3f275

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

Doc/tools/mkhowto

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,9 @@ class Job:
442442
self.warning(
443443
"Session transcript and error messages are in %s."
444444
% self.log_filename)
445+
sys.stderr.write("The relevant lines from the transcript are:\n")
446+
sys.stderr.write("-" * 72 + "\n")
447+
sys.stderr.writelines(get_run_transcript(self.log_filename))
445448
sys.exit(rc)
446449

447450
def message(self, msg):
@@ -461,7 +464,23 @@ class Job:
461464
fp.close()
462465

463466

467+
def get_run_transcript(filename):
468+
"""Return lines from the transcript file for the most recent run() call."""
469+
fp = open(filename)
470+
lines = fp.readlines()
471+
fp.close()
472+
lines.reverse()
473+
L = []
474+
for line in lines:
475+
L.append(line)
476+
if line[:4] == "+++ ":
477+
break
478+
L.reverse()
479+
return L
480+
481+
464482
def safe_unlink(path):
483+
"""Unlink a file without raising an error if it doesn't exist."""
465484
try:
466485
os.unlink(path)
467486
except os.error:

0 commit comments

Comments
 (0)