From 8b4b2507fa841af1816493a9380230d9b6b46da5 Mon Sep 17 00:00:00 2001 From: Xarvex Date: Wed, 24 Apr 2024 23:50:26 -0500 Subject: [PATCH] Account for start being a shell builtin on Windows --- tagstudio/src/qt/ts_qt.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/tagstudio/src/qt/ts_qt.py b/tagstudio/src/qt/ts_qt.py index 1695690f..57e056a9 100644 --- a/tagstudio/src/qt/ts_qt.py +++ b/tagstudio/src/qt/ts_qt.py @@ -59,20 +59,21 @@ logging.basicConfig(format="%(message)s", level=logging.INFO) def open_file(path: str): - if sys.platform == "win32": - command_name = "start" - elif sys.platform == "darwin": - command_name = "open" - else: - command_name = "xdg-open" - command = shutil.which(command_name) - if command is not None: - try: - subprocess.Popen([command, path], close_fds=True) - except: - traceback.print_exc() - else: - logging.info(f"Could not find {command_name} on system PATH") + try: + if sys.platform == "win32": + subprocess.Popen(["start", path], shell=True, close_fds=True) + else: + if sys.platform == "darwin": + command_name = "open" + else: + command_name = "xdg-open" + command = shutil.which(command_name) + if command is not None: + subprocess.Popen([command, path], close_fds=True) + else: + logging.info(f"Could not find {command_name} on system PATH") + except: + traceback.print_exc() class NavigationState():