[Python-checkins] CVS: python/dist/src/Doc/tools mkhowto,1.20,1.21
Fred L. Drake
fdrake@users.sourceforge.net
Sun, 04 Feb 2001 07:20:28 -0800
Update of /cvsroot/python/python/dist/src/Doc/tools
In directory usw-pr-cvs1:/tmp/cvs-serv29037
Modified Files:
mkhowto
Log Message:
Improve diagnostic output when an external command returns a non-zero exit
code, showing the transcript for that command.
This closes SF bug #129740.
Index: mkhowto
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/tools/mkhowto,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -r1.20 -r1.21
*** mkhowto 2001/01/30 22:30:01 1.20
--- mkhowto 2001/02/04 15:20:26 1.21
***************
*** 443,446 ****
--- 443,449 ----
"Session transcript and error messages are in %s."
% self.log_filename)
+ sys.stderr.write("The relevant lines from the transcript are:\n")
+ sys.stderr.write("-" * 72 + "\n")
+ sys.stderr.writelines(get_run_transcript(self.log_filename))
sys.exit(rc)
***************
*** 462,466 ****
--- 465,485 ----
+ def get_run_transcript(filename):
+ """Return lines from the transcript file for the most recent run() call."""
+ fp = open(filename)
+ lines = fp.readlines()
+ fp.close()
+ lines.reverse()
+ L = []
+ for line in lines:
+ L.append(line)
+ if line[:4] == "+++ ":
+ break
+ L.reverse()
+ return L
+
+
def safe_unlink(path):
+ """Unlink a file without raising an error if it doesn't exist."""
try:
os.unlink(path)