Merge branch 'main' into feature/modify-imports

This commit is contained in:
Travis Abendshien
2024-04-24 22:36:56 -07:00
committed by GitHub

View File

@@ -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()