Fix temp file handling for Windows
This commit is contained in:
parent
600d8eaea9
commit
4343da522e
|
@ -1,6 +1,7 @@
|
||||||
import webbrowser
|
import webbrowser
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
|
import os
|
||||||
import markdown
|
import markdown
|
||||||
import navpoint.fix_path
|
import navpoint.fix_path
|
||||||
|
|
||||||
|
@ -19,7 +20,10 @@ def about():
|
||||||
with open(navpoint.fix_path.fix_path("CC-BY-SA-4.0.txt")) as f:
|
with open(navpoint.fix_path.fix_path("CC-BY-SA-4.0.txt")) as f:
|
||||||
cc = f.read()
|
cc = f.read()
|
||||||
|
|
||||||
with tempfile.NamedTemporaryFile("w+") as f:
|
fd, name = tempfile.mkstemp(suffix=".html")
|
||||||
|
os.close(fd)
|
||||||
|
|
||||||
|
with open(name, "w") as f:
|
||||||
f.write(
|
f.write(
|
||||||
f"""\
|
f"""\
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
@ -39,6 +43,7 @@ def about():
|
||||||
</html>
|
</html>
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
f.flush()
|
|
||||||
webbrowser.open(f.name)
|
webbrowser.open(name)
|
||||||
time.sleep(0.5) # Give the browser time to open the file
|
time.sleep(0.5) # Give the browser time to open the file
|
||||||
|
os.remove(name)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user