From 2f84bbe9a6dc6ca2d9a49eae0bf094744e47f11d Mon Sep 17 00:00:00 2001 From: Julien Rioux Date: Tue, 13 Mar 2012 16:50:16 -0400 Subject: [PATCH] Build: Better error handling from build scripts. --- scripts/build/bib2texi.py | 10 ++++++++-- scripts/build/genicon.py | 2 +- scripts/build/mf-to-table.py | 12 +++++++++--- scripts/build/mf2pt1.pl | 2 +- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/scripts/build/bib2texi.py b/scripts/build/bib2texi.py index ab8a6b902b..c71976dec1 100644 --- a/scripts/build/bib2texi.py +++ b/scripts/build/bib2texi.py @@ -69,15 +69,21 @@ cmd = "TEXMFOUTPUT=%s bibtex %s %s" % (tmpdir, quiet_flag, tmpfile) if (show_output): sys.stdout.write ("Running bibtex on %s\n" % files) + sys.stdout.write (cmd) #And invoke it stat = os.system (cmd) if stat <> 0: - sys.exit(1) + sys.stderr.write ("Bibtex exited with nonzero exit status!") + sys.exit (1) #TODO: do tex -> itexi on output -# Following 2 lines copy tmpfile.bbl to the desired output file +# Following lines copy tmpfile.bbl to the desired output file bbl = open (tmpfile + '.bbl').read () +if bbl.strip () == '': + sys.stderr.write ("Bibtex generated an empty file!") + sys.exit (1) + open (output, 'w').write (bbl) def cleanup (tmpfile): diff --git a/scripts/build/genicon.py b/scripts/build/genicon.py index 543735240f..b96730b769 100644 --- a/scripts/build/genicon.py +++ b/scripts/build/genicon.py @@ -15,7 +15,7 @@ os.chdir(dir) def system (c): print c if os.system (c): - raise 'barf' + raise Exception('The command exited with nonzero exit status!') outputs = [] for sz in [48,32,16] : diff --git a/scripts/build/mf-to-table.py b/scripts/build/mf-to-table.py index 44f0edc33a..f191d0aa8f 100644 --- a/scripts/build/mf-to-table.py +++ b/scripts/build/mf-to-table.py @@ -27,7 +27,7 @@ import time def read_log_file (fn): str = open (fn).read () - str = re.sub ('\n', '', str) + str = re.sub ('[\n\r]', '', str) str = re.sub ('[\t ]+', ' ', str) deps = [] @@ -61,14 +61,20 @@ def parse_logfile (fn): } group = '' - for l in autolines: + for i, l in enumerate(autolines): tags = l.split ('@:') if tags[0] == 'group': group = tags[1] elif tags[0] == 'puorg': group = '' elif tags[0] == 'char': - name = tags[9] + try: + name = tags[9] + except IndexError: + print 'Error in mf-to-table while processing file', fn + print 'Index 9 >', len(tags)-1, 'on line', i + print l + raise if group: name = group + '.' + name diff --git a/scripts/build/mf2pt1.pl b/scripts/build/mf2pt1.pl index 3a39a126d4..befe8bc3e2 100644 --- a/scripts/build/mf2pt1.pl +++ b/scripts/build/mf2pt1.pl @@ -427,7 +427,7 @@ ENDHEADER sub get_bboxes ($) { execute_command 1, ("mpost", "-mem=mf2pt1", "-progname=mpost", - "\\mode:=localfont; mag:=$mag; bpppix $bpppix; input $mffile"); + "\\mode:=localfont; mag:=$mag; bpppix $bpppix; nonstopmode; input $mffile"); opendir (CURDIR, ".") || die "${progname}: $! ($filedir)\n"; @charfiles = sort { ($a=~ /\.(\d+)$/)[0] <=> ($b=~ /\.(\d+)$/)[0] } -- 2.39.2