diff options
author | Reinhold Kainhofer <reinhold@kainhofer.com> | 2011-08-22 13:59:16 +0200 |
---|---|---|
committer | Reinhold Kainhofer <reinhold@kainhofer.com> | 2011-08-30 20:49:53 +0200 |
commit | ff4a77f00d352158e487637b0a537281fd63db1a (patch) | |
tree | 18509bc788db0ad83f448095a6775d93144581a0 /python/book_latex.py | |
parent | 5d46c7466c5902d40825c0a5f5ab1c67dbc1591a (diff) |
Lilypond-book: don't crash in linewidth detection in latex mode when latex cannot be executed
This also makes an existing latex installation a recommendation for lilypond-book rather than a hard requirement.
Diffstat (limited to 'python/book_latex.py')
-rw-r--r-- | python/book_latex.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/python/book_latex.py b/python/book_latex.py index 8097443f7f..fbf98e66bf 100644 --- a/python/book_latex.py +++ b/python/book_latex.py @@ -3,6 +3,7 @@ import re import tempfile import os +import subprocess import book_base as BookBase from book_snippets import * import lilylib as ly @@ -180,12 +181,20 @@ def get_latex_textwidth (source, global_options): tmp_handle.write (latex_document) tmp_handle.close () - ly.system ('%s %s' % (global_options.latex_program, tmpfile), - be_verbose=global_options.verbose) - parameter_string = file (logfile).read() - + progress (_ ("Running `%s' on file `%s' to detect default page settings.\n") + % (global_options.latex_program, tmpfile)); + cmd = '%s %s' % (global_options.latex_program, tmpfile); + proc = subprocess.Popen (cmd, + universal_newlines=True, shell=True, + stdout=subprocess.PIPE, stderr=subprocess.PIPE); + if proc.returncode != 0: + warning (_ ("Unable to auto-detect default page settings:\n%s") + % proc.communicate ()[1]); os.unlink (tmpfile) - os.unlink (logfile) + parameter_string = "" + if os.path.exists (logfile): + parameter_string = file (logfile).read() + os.unlink (logfile) columns = 0 m = re.search ('columns=([0-9.]+)', parameter_string) |