Browse Source

Report if the latex executable is not found

pull/145/merge
Oliverpool 9 years ago
parent
commit
b462cc2770
  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)) LOGGER.info("Building '{}.pdf'".format(self.basename))
self._run_once(self._set_latex) 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: try:
process = Popen( process = Popen(
["lualatex"] + self._lualatex_options + [self.basename], [compiler] + self._lualatex_options + [self.basename],
stdin=PIPE, stdin=PIPE,
stdout=PIPE, stdout=PIPE,
stderr=PIPE, stderr=PIPE,

12
patacrep/errors.py

@ -31,6 +31,16 @@ class TemplateError(SongbookError):
else: else:
return self.message 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): class StepError(SongbookError):
"""Error during execution of one compilation step.""" """Error during execution of one compilation step."""
@ -47,7 +57,7 @@ class LatexCompilationError(StepError):
def __init__(self, basename): def __init__(self, basename):
super(LatexCompilationError, self).__init__( super(LatexCompilationError, self).__init__(
( (
"""Error while pdfLaTeX compilation of "{basename}.tex" """ """Error while LaTeX compilation of "{basename}.tex" """
"""(see {basename}.log for more information).""" """(see {basename}.log for more information)."""
).format(basename=basename) ).format(basename=basename)
) )

Loading…
Cancel
Save