improve temp file search when using latex to prevent overwriting files
This commit is contained in:
parent
5b48225d0c
commit
b5c424a96f
|
@ -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}'
|
||||
|
|
Loading…
Reference in New Issue