From 1da076773d523f6cd0cd8f233e6f8ae73a693391 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Mon, 9 Nov 2015 07:30:11 +0100 Subject: [PATCH] Test for lilypond compiler before starting compilation --- patacrep/build.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/patacrep/build.py b/patacrep/build.py index a720b9b1..f3391744 100644 --- a/patacrep/build.py +++ b/patacrep/build.py @@ -123,6 +123,9 @@ class Songbook(object): renderer.render_tex(output, config) + def requires_lilypond(self): + return 'lilypond' in self.config.get('bookoptions', []) + def _log_pipe(pipe): """Log content from `pipe`.""" while 1: @@ -227,6 +230,20 @@ class SongbookBuilder(object): except Exception as error: raise errors.ExecutableNotFound(compiler) + # Test if lilypond compiler is accessible + lilypond_compiler = 'lilypond' + if self.songbook.requires_lilypond(): + try: + check_call( + [lilypond_compiler, "--version"], + stdin=PIPE, + stdout=PIPE, + stderr=PIPE, + universal_newlines=True, + ) + except Exception as error: + raise errors.ExecutableNotFound(lilypond_compiler) + # Perform compilation try: process = Popen(