From 91e10566b9f09ace78156acc70f2c9afbf035eb1 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Fri, 30 Oct 2015 13:15:34 +0100 Subject: [PATCH] Report if the latex executable is not found --- patacrep/build.py | 17 ++++++++++++++++- patacrep/errors.py | 12 +++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/patacrep/build.py b/patacrep/build.py index 00be667e..d260d45b 100644 --- a/patacrep/build.py +++ b/patacrep/build.py @@ -217,9 +217,24 @@ class SongbookBuilder(object): LOGGER.info("Building '{}.pdf'…".format(self.basename)) self._run_once(self._set_latex) + compiler = "lualatex" + + # test if the LaTeX compiler is accessible + try: + process = Popen( + [compiler, "--version"], + stdin=PIPE, + stdout=PIPE, + stderr=PIPE, + env=os.environ, + universal_newlines=True, + ) + except Exception as error: + raise errors.ExecutableNotFound(compiler) + try: process = Popen( - ["lualatex"] + self._lualatex_options + [self.basename], + [compiler] + self._lualatex_options + [self.basename], stdin=PIPE, stdout=PIPE, stderr=PIPE, diff --git a/patacrep/errors.py b/patacrep/errors.py index 5ec9fd9b..d1d3a74f 100644 --- a/patacrep/errors.py +++ b/patacrep/errors.py @@ -31,6 +31,16 @@ class TemplateError(SongbookError): else: return self.message +class ExecutableNotFound(SongbookError): + """Couldn't find a LaTeX executable.""" + + def __init__(self, executable): + super(ExecutableNotFound, self).__init__( + ( + """Could not find the following executable: {executable}""" + ).format(executable=executable) + ) + class StepError(SongbookError): """Error during execution of one compilation step.""" @@ -47,7 +57,7 @@ class LatexCompilationError(StepError): def __init__(self, basename): super(LatexCompilationError, self).__init__( ( - """Error while pdfLaTeX compilation of "{basename}.tex" """ + """Error while LaTeX compilation of "{basename}.tex" """ """(see {basename}.log for more information).""" ).format(basename=basename) )