From 1467767c8e26f2fe5d318114c8e0055be1c10c8e Mon Sep 17 00:00:00 2001 From: Keuin Date: Sat, 3 Jun 2023 15:26:02 +0800 Subject: Generate using temporary tex file --- texgen.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'texgen.py') diff --git a/texgen.py b/texgen.py index 851df83..f629094 100644 --- a/texgen.py +++ b/texgen.py @@ -40,13 +40,15 @@ class TexGenerator: return cache_file_path with temp_dir(os.path.join(self._temp_path, os.urandom(24).hex())) as workdir: job_name = 'texput' + tex_file_path = os.path.join(self._temp_path, f'{job_name}.tex') + with open(tex_file_path, 'w', encoding='utf-8') as f: + f.write(tex_source) with subprocess.Popen( [ 'xelatex', '-interaction=nonstopmode', '-halt-on-error', - # this seems not working, as the output file name is always set to default `texput.pdf` - f'-jobname={job_name}', + tex_file_path, ], cwd=workdir, stdin=subprocess.PIPE, @@ -55,7 +57,7 @@ class TexGenerator: text=True, shell=True, ) as proc: - stdout, stderr = proc.communicate(input=tex_source, timeout=self._task_timeout) + stdout, stderr = proc.communicate(input='', timeout=self._task_timeout) print('STDOUT', stdout) print('STDERR', stderr) if proc.returncode != 0: -- cgit v1.2.3