]> git.donarmstrong.com Git - lilypond.git/commitdiff
(LatexPaper.find_latex_dims): give more
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 30 Aug 2002 21:48:52 +0000 (21:48 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 30 Aug 2002 21:48:52 +0000 (21:48 +0000)
meaningful error if running latex fails

ChangeLog
scripts/lilypond-book.py

index dc1190e500e01aa3be73b7c55fe85cdd3c16a597..114f97bceaf4621c1bbe44160813a28511b0d555 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2002-08-30  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
 
+       * scripts/lilypond-book.py (LatexPaper.find_latex_dims): give more
+       meaningful error if running latex fails 
+
        * Documentation/user/refman.itely (Tablatures): small
        corrections. Thanks to Karl Berry
 
index c308b5a001c797d0a0d7fda0b85c9a60fad795a9..2030b14c475e4bf05fbade711166c517e2a8206c 100644 (file)
@@ -190,22 +190,48 @@ class LatexPaper:
 
                cmd = "latex '\\nonstopmode \input %s'" % fname
                if verbose_p:
-                       sys.stderr.write ("Invoking `%s' as pipe" % cmd) 
-               p = os.popen(cmd)
-               ln = p.readline()
-               while ln:
+                       sys.stderr.write ("Invoking `%s' as pipe" % cmd)
+               try:
+                       status = quiet_system (cmd, "Latex for finding dimensions")
+               except:
+                       sys.stderr.write (_("Invoking LaTeX failed.") + '\n' )
+                       sys.stderr.write (_("This is the error log:\n") + '\n')
+
+                       lns = open ('lily-tmp.log').readlines()
+
+                       countdown = -3
+                       for ln in lns:
+                               sys.stderr.write (ln)
+                               if re.match('^!', ln):
+                                       countdown = 3
+
+                               if countdown == 0:
+                                       break
+                               
+                               if countdown > 0:
+                                       countdown = countdown -1
+
+                       sys.stderr.write ("  ... (further messages elided)...\n")
+                       sys.exit (1)
+                       
+               lns = open ('lily-tmp.log').readlines()
+               for ln in lns:
                        ln = string.strip(ln)
                        m = re_dim.match(ln)
                        if m:
                                if m.groups()[0] in ('textwidth', 'columnsep'):
                                        self.__dict__['m_%s' % m.groups()[0]] = float(m.groups()[1])
-                       ln = p.readline()
+                                       
                try:
                        os.remove (fname)
                        os.remove (os.path.splitext(fname)[0]+".aux")
                        os.remove (os.path.splitext(fname)[0]+".log")
                except:
                        pass
+
+               if not self.__dict__.has_key ('m_textwidth'):
+                       raise 'foo!'
+               
        def get_linewidth(self):
                if self.m_num_cols == 1:
                        w = self.m_textwidth