Browse Source

Report if the latex executable is not found

pull/149/head
Oliverpool 9 years ago
parent
commit
91e10566b9
  1. 17
      patacrep/build.py
  2. 12
      patacrep/errors.py

17
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,

12
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)
)

Loading…
Cancel
Save