From dd7ceab88778adeb7f3f549e85991b2b694a1232 Mon Sep 17 00:00:00 2001 From: Luthaf Date: Wed, 9 Apr 2014 20:54:46 +0100 Subject: [PATCH] =?UTF-8?q?La=20sortie=20LaTeX=20est=20redirig=C3=A9e=20ve?= =?UTF-8?q?rs=20le=20logger.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- songbook | 2 +- songbook_core/build.py | 22 +++++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/songbook b/songbook index 1e9aefbc..20392cf4 100755 --- a/songbook +++ b/songbook @@ -75,7 +75,7 @@ def main(): """Main function:""" # Logging configuration - logging.basicConfig(name='songbook') + logging.basicConfig(name='songbook', level=logging.INFO) logger = logging.getLogger('songbook') # set script locale to match user's diff --git a/songbook_core/build.py b/songbook_core/build.py index 31f65a6c..7479b1c5 100644 --- a/songbook_core/build.py +++ b/songbook_core/build.py @@ -228,9 +228,25 @@ class SongbookBuilder(object): def build_pdf(self): """Build .pdf file from .tex file""" self._run_once(self._set_latex) - if subprocess.call( - ["pdflatex"] + self._pdflatex_options + [self.basename] - ): + from subprocess import Popen, PIPE + + #if self.logger: + # out = self.logger.stream + #else: + # out = None + + p = Popen( + ["pdflatex"] + self._pdflatex_options + [self.basename], + stdout=PIPE, + stderr=PIPE) + log = '' + line = p.stdout.readline() + while line: + log += line + line = p.stdout.readline() + self.logger.info(log) + + if p.returncode: raise errors.LatexCompilationError(self.basename) def build_sbx(self):