From f55bb4255d5ff83377715e36ef9d0316edd3c924 Mon Sep 17 00:00:00 2001 From: Mark Janssen <20283+praseodym@users.noreply.github.com> Date: Wed, 5 Apr 2023 13:52:50 +0200 Subject: [PATCH] Log pdflatex output on error (#667) Co-authored-by: ammar92 --- keiko/keiko/keiko.py | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/keiko/keiko/keiko.py b/keiko/keiko/keiko.py index d70c01e1cf8..9c66551545a 100644 --- a/keiko/keiko/keiko.py +++ b/keiko/keiko/keiko.py @@ -121,24 +121,22 @@ def generate_report( tex_output_file_name, ] env = {**os.environ, "TEXMFVAR": tmp_dirname} - output = subprocess.run(cmd, cwd=tmp_dirname, env=env, capture_output=True, check=False) - logger.info("pdflatex run. [report_id=%s] [template=%s] [command=%s]", report_id, template_name, " ".join(cmd)) - logger.debug(output.stdout.decode("utf-8")) - logger.debug(output.stderr.decode("utf-8")) - if output.returncode: - raise Exception("Error running pdflatex") - - output = subprocess.run(cmd, cwd=tmp_dirname, env=env, capture_output=True, check=False) - logger.info( - "pdflatex run. [report_id=%s] [template=%s] [command=%s]", - report_id, - template_name, - " ".join(cmd), - ) - logger.debug(output.stdout.decode("utf-8")) - logger.debug(output.stderr.decode("utf-8")) - if output.returncode: - raise Exception("Error running pdflatex") + for i in (1, 2): + output = subprocess.run(cmd, cwd=tmp_dirname, env=env, capture_output=True, check=False) + logger.info( + "pdflatex [run=%d] [report_id=%s] [template=%s] [command=%s]", + i, + report_id, + template_name, + " ".join(cmd), + ) + if output.returncode: + logger.error("stdout: %s", output.stdout.decode("utf-8")) + logger.error("stderr: %s", output.stderr.decode("utf-8")) + raise Exception("Error in pdflatex run %d", i) + else: + logger.debug(output.stdout.decode("utf-8")) + logger.debug(output.stderr.decode("utf-8")) # copy result back to output folder Path(settings.reports_folder).mkdir(parents=True, exist_ok=True)