Skip to content
Snippets Groups Projects
Commit b5c424a9 authored by Yann Leboulanger's avatar Yann Leboulanger
Browse files

improve temp file search when using latex to prevent overwriting files

parent 5b48225d
No related branches found
No related tags found
No related merge requests found
......@@ -59,8 +59,19 @@ def check_blacklist(str_):
def get_tmpfile_name():
random.seed()
int_ = random.randint(0, 100)
return os.path.join(gettempdir(), 'gajimtex_' + int_.__str__())
while(nb < 100):
int_ = random.randint(0, 10000)
filename = os.path.join(gettempdir(), 'gajimtex_' + int_.__str__())
# Check if a file to not overwrite it
ok = True
extensions = ['.tex', '.log', '.aux', '.dvi']
for ext in extensions:
if os.path.exists(filename + ext):
ok = False
break
if ok:
return filename
return filename
def write_latex(filename, str_):
texstr = '\\documentclass[12pt]{article}\\usepackage[dvips]{graphicx}'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment