mirror of
https://github.com/TagStudioDev/TagStudio.git
synced 2026-02-01 23:59:10 +00:00
Merge branch 'main' into feature/modify-imports
This commit is contained in:
@@ -14,6 +14,8 @@ import os
|
||||
import sys
|
||||
import time
|
||||
import traceback
|
||||
import shutil
|
||||
import subprocess
|
||||
from types import FunctionType
|
||||
from datetime import datetime as dt
|
||||
from pathlib import Path
|
||||
@@ -60,11 +62,20 @@ INFO = f'[INFO]'
|
||||
logging.basicConfig(format="%(message)s", level=logging.INFO)
|
||||
|
||||
|
||||
def open_file(path):
|
||||
def open_file(path: str):
|
||||
try:
|
||||
os.startfile(path)
|
||||
except FileNotFoundError:
|
||||
logging.info('File Not Found! (Imagine this as a popup)')
|
||||
if sys.platform == "win32":
|
||||
subprocess.Popen(["start", path], shell=True, close_fds=True, creationflags=subprocess.DETACHED_PROCESS)
|
||||
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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user