fix opening log file on macos and linux

This commit is contained in:
dries.k
2022-08-21 17:42:30 +02:00
parent 966b86ce12
commit ff392f96c1
2 changed files with 13 additions and 3 deletions

View File

@@ -1,5 +1,7 @@
import os
import platform
import re
import subprocess
from pathlib import Path
@@ -46,3 +48,12 @@ def get_abs_path(s) -> str:
h = Path(__file__).parent.parent
p = Path(s)
return os.path.join(h, p).replace("\\", "/")
def open_file(filename: str):
if platform.system() == "Linux":
subprocess.call(["xdg-open", filename])
elif platform.system() == "Windows":
os.startfile(filename)
elif platform.system() == "Darwin":
subprocess.call(["open", filename])