Browse Source

Merge pull request #169 from patacrep/lilypond_compiler

Test for lilypond compiler before starting compilation
pull/188/head
oliverpool 9 years ago
parent
commit
72e3c202b9
  1. 20
      patacrep/build.py

20
patacrep/build.py

@ -113,6 +113,10 @@ class Songbook(object):
renderer.render_tex(output, config) renderer.render_tex(output, config)
def requires_lilypond(self):
"""Tell if lilypond is part of the bookoptions"""
return 'lilypond' in self.config.get('bookoptions', [])
def _log_pipe(pipe): def _log_pipe(pipe):
"""Log content from `pipe`.""" """Log content from `pipe`."""
while 1: while 1:
@ -214,9 +218,23 @@ class SongbookBuilder(object):
stderr=PIPE, stderr=PIPE,
universal_newlines=True, universal_newlines=True,
) )
except Exception as error: except FileNotFoundError as error:
raise errors.ExecutableNotFound(compiler) raise errors.ExecutableNotFound(compiler)
# Test if lilypond compiler is accessible
if self.songbook.requires_lilypond():
lilypond_compiler = 'lilypond'
try:
check_call(
[lilypond_compiler, "--version"],
stdin=PIPE,
stdout=PIPE,
stderr=PIPE,
universal_newlines=True,
)
except FileNotFoundError as error:
raise errors.ExecutableNotFound(lilypond_compiler)
# Perform compilation # Perform compilation
try: try:
process = Popen( process = Popen(

Loading…
Cancel
Save