mirror of https://github.com/eyhc1/rendercv.git
improve TinyTeX call
This commit is contained in:
parent
a21af89f08
commit
76a2de4d6e
|
@ -428,24 +428,32 @@ def run_latex(latex_file_path: str) -> str:
|
||||||
" RenderCV again."
|
" RenderCV again."
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
# Run TinyTeX:
|
||||||
subprocess.run(
|
with subprocess.Popen(
|
||||||
[
|
[
|
||||||
executable,
|
executable,
|
||||||
f"{latex_file_name}",
|
f"{latex_file_name}",
|
||||||
],
|
],
|
||||||
cwd=os.path.dirname(latex_file_path),
|
cwd=os.path.dirname(latex_file_path),
|
||||||
check=True,
|
stdout=subprocess.PIPE,
|
||||||
stdout=subprocess.DEVNULL, # suppress latexmk output
|
stdin=subprocess.DEVNULL, # don't allow TinyTeX to ask for user input
|
||||||
timeout=45,
|
text=True,
|
||||||
)
|
) as latex_process:
|
||||||
except subprocess.CalledProcessError or subprocess.TimeoutExpired as e:
|
output, error = latex_process.communicate()
|
||||||
raise RuntimeError(
|
output.split("\n")
|
||||||
"Running TinyTeX has failed with the following error:\n\ncommand"
|
|
||||||
f' "{e.cmd}" return with error (code {e.returncode}): {e.output}\n\nIf'
|
if latex_process.returncode != 0:
|
||||||
" you can't find the problem, please try to re-install RenderCV, or open"
|
# Find the error line:
|
||||||
" an issue on GitHub."
|
for line in output.split("\n"):
|
||||||
)
|
if line.startswith("! "):
|
||||||
|
error_line = line.replace("! ", "")
|
||||||
|
break
|
||||||
|
|
||||||
|
raise RuntimeError(
|
||||||
|
"Running TinyTeX has failed with the following error:\n\n"
|
||||||
|
f"{error_line}\n\nIf you can't solve the problem, please try to"
|
||||||
|
" re-install RenderCV, or open an issue on GitHub."
|
||||||
|
)
|
||||||
|
|
||||||
# check if the PDF file is generated:
|
# check if the PDF file is generated:
|
||||||
if not os.path.exists(output_file_path):
|
if not os.path.exists(output_file_path):
|
||||||
|
|
Loading…
Reference in New Issue