From face4ce3a7059cf816b8eadf2858f336de9d465b Mon Sep 17 00:00:00 2001 From: Mark Janssen <20283+praseodym@users.noreply.github.com> Date: Wed, 5 Apr 2023 12:13:34 +0200 Subject: [PATCH 1/4] Log pdflatex output on error Log stdout and stderr when pdflatex exits with a non-zero return code. --- 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..8ab60e50422 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 range(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(output.stdout.decode("utf-8")) + logger.error(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) From d63a23fd5fd9b56813ce1115cf4a8ba257fd13d3 Mon Sep 17 00:00:00 2001 From: Mark Janssen <20283+praseodym@users.noreply.github.com> Date: Wed, 5 Apr 2023 12:19:06 +0200 Subject: [PATCH 2/4] Update keiko/keiko/keiko.py Co-authored-by: ammar92 --- keiko/keiko/keiko.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/keiko/keiko/keiko.py b/keiko/keiko/keiko.py index 8ab60e50422..f29b92a5f37 100644 --- a/keiko/keiko/keiko.py +++ b/keiko/keiko/keiko.py @@ -131,8 +131,8 @@ def generate_report( " ".join(cmd), ) if output.returncode: - logger.error(output.stdout.decode("utf-8")) - logger.error(output.stderr.decode("utf-8")) + 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")) From 44e01db399bb2f452c9ca16ce40bcce540f319f0 Mon Sep 17 00:00:00 2001 From: Mark Janssen <20283+praseodym@users.noreply.github.com> Date: Wed, 5 Apr 2023 12:19:12 +0200 Subject: [PATCH 3/4] Update keiko/keiko/keiko.py Co-authored-by: ammar92 --- keiko/keiko/keiko.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keiko/keiko/keiko.py b/keiko/keiko/keiko.py index f29b92a5f37..baae739e18b 100644 --- a/keiko/keiko/keiko.py +++ b/keiko/keiko/keiko.py @@ -121,7 +121,7 @@ def generate_report( tex_output_file_name, ] env = {**os.environ, "TEXMFVAR": tmp_dirname} - for i in range(2): + for i in enumerate(range(2), 1): 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]", From 61fd85a2372a31dc0bcea7cd10a76b13a18fe746 Mon Sep 17 00:00:00 2001 From: ammar92 Date: Wed, 5 Apr 2023 13:01:31 +0200 Subject: [PATCH 4/4] Update keiko.py --- keiko/keiko/keiko.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keiko/keiko/keiko.py b/keiko/keiko/keiko.py index baae739e18b..9c66551545a 100644 --- a/keiko/keiko/keiko.py +++ b/keiko/keiko/keiko.py @@ -121,7 +121,7 @@ def generate_report( tex_output_file_name, ] env = {**os.environ, "TEXMFVAR": tmp_dirname} - for i in enumerate(range(2), 1): + 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]",