Copy output file from temporary directory

This commit is contained in:
Nick Hall 2018-02-14 22:43:40 +00:00
parent 2fbb9878c2
commit e202f5cd19

View File

@ -25,6 +25,7 @@
#-------------------------------------------------------------------------
from abc import ABCMeta, abstractmethod
import os
import shutil
from subprocess import Popen, PIPE
from io import StringIO
import tempfile
@ -606,14 +607,16 @@ class TreePdfDoc(TreeDocBase):
self._filename += ".pdf"
with tempfile.TemporaryDirectory() as tmpdir:
basename = os.path.basename(self._filename)
args = ['lualatex', '-output-directory', tmpdir,
'-jobname', self._filename[:-4]]
'-jobname', basename[:-4]]
if win():
proc = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE,
creationflags=DETACHED_PROCESS)
else:
proc = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE)
proc.communicate(input=self._tex.getvalue().encode('utf-8'))
shutil.copy(os.path.join(tmpdir, basename), self._filename)
#------------------------------------------------------------------------------