Improved stability for Windows NT OS

This commit is contained in:
Solara570 2017-09-27 17:29:13 +08:00
parent 9958a73059
commit 68771e105a
2 changed files with 14 additions and 3 deletions

View file

@ -294,6 +294,11 @@ def generate_tex_file(expression, template_tex_file):
outfile.write(body) outfile.write(body)
return result return result
def get_null():
if os.name == "nt":
return "NUL"
return "/dev/null"
def tex_to_dvi(tex_file): def tex_to_dvi(tex_file):
result = tex_file.replace(".tex", ".dvi") result = tex_file.replace(".tex", ".dvi")
if not os.path.exists(result): if not os.path.exists(result):
@ -303,7 +308,8 @@ def tex_to_dvi(tex_file):
"-halt-on-error", "-halt-on-error",
"-output-directory=" + TEX_DIR, "-output-directory=" + TEX_DIR,
tex_file, tex_file,
"> /dev/null" ">",
get_null()
] ]
exit_code = os.system(" ".join(commands)) exit_code = os.system(" ".join(commands))
if exit_code != 0: if exit_code != 0:
@ -334,7 +340,8 @@ def dvi_to_svg(dvi_file, regen_if_exists = False):
"0", "0",
"-o", "-o",
result, result,
"> /dev/null" ">",
get_null()
] ]
os.system(" ".join(commands)) os.system(" ".join(commands))
return result return result

View file

@ -5,6 +5,7 @@ import itertools as it
import warnings import warnings
import time import time
import os import os
import shutil
import copy import copy
from tqdm import tqdm as ProgressDisplay from tqdm import tqdm as ProgressDisplay
import inspect import inspect
@ -497,6 +498,9 @@ class Scene(object):
def close_movie_pipe(self): def close_movie_pipe(self):
self.writing_process.stdin.close() self.writing_process.stdin.close()
self.writing_process.wait() self.writing_process.wait()
if os.name == 'nt':
shutil.move(*self.args_to_rename_file)
else:
os.rename(*self.args_to_rename_file) os.rename(*self.args_to_rename_file)