File tree Expand file tree Collapse file tree 1 file changed +17
-7
lines changed Expand file tree Collapse file tree 1 file changed +17
-7
lines changed Original file line number Diff line number Diff line change 41
41
# from typing_extensions import deprecated
42
42
from humanfriendly import format_timespan
43
43
# from src.qt.qtacrylic.qtacrylic import WindowEffect
44
+ import shutil
45
+ import subprocess
44
46
45
47
# SIGQUIT is not defined on Windows
46
48
if sys .platform == "win32" :
56
58
logging .basicConfig (format = "%(message)s" , level = logging .INFO )
57
59
58
60
59
- def open_file (path ):
60
- try :
61
- os .startfile (path )
62
- except FileNotFoundError :
63
- logging .info ('File Not Found! (Imagine this as a popup)' )
64
- except :
65
- traceback .print_exc ()
61
+ def open_file (path : str ):
62
+ if sys .platform == "win32" :
63
+ command_name = "start"
64
+ elif sys .platform == "darwin" :
65
+ command_name = "open"
66
+ else :
67
+ command_name = "xdg-open"
68
+ command = shutil .which (command_name )
69
+ if command is not None :
70
+ try :
71
+ subprocess .Popen ([command , path ], close_fds = True )
72
+ except :
73
+ traceback .print_exc ()
74
+ else :
75
+ logging .info (f"Could not find { command_name } on system PATH" )
66
76
67
77
68
78
class NavigationState ():
You can’t perform that action at this time.
0 commit comments