From 4343da522eea704c1d14b9d43ae6419ae1131168 Mon Sep 17 00:00:00 2001 From: Samuel Sloniker Date: Sun, 28 Jul 2024 16:41:04 -0700 Subject: [PATCH] Fix temp file handling for Windows --- navpoint/about.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/navpoint/about.py b/navpoint/about.py index 686dea3..a94c9af 100644 --- a/navpoint/about.py +++ b/navpoint/about.py @@ -1,6 +1,7 @@ import webbrowser import tempfile import time +import os import markdown 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: 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"""\ @@ -39,6 +43,7 @@ def about(): """ ) - f.flush() - webbrowser.open(f.name) - time.sleep(0.5) # Give the browser time to open the file + + webbrowser.open(name) + time.sleep(0.5) # Give the browser time to open the file + os.remove(name)