Skip to content

Commit

Permalink
Log pdflatex output on error (#667)
Browse files Browse the repository at this point in the history
Co-authored-by: ammar92 <[email protected]>
  • Loading branch information
praseodym and ammar92 authored Apr 5, 2023
1 parent f8fdd1c commit f55bb42
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions keiko/keiko/keiko.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f55bb42

Please sign in to comment.