fix opening log file on macos and linux
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
import logging
|
||||
import platform
|
||||
import os
|
||||
import webbrowser
|
||||
|
||||
from gotify_tray.database import Settings
|
||||
from gotify_tray.gotify import GotifyMessageModel
|
||||
from gotify_tray.gui.models import MessagesModelItem
|
||||
from . import MessageWidget
|
||||
from gotify_tray.utils import verify_server
|
||||
from gotify_tray.utils import verify_server, open_file
|
||||
from gotify_tray.tasks import ExportSettingsTask, ImportSettingsTask
|
||||
from PyQt6 import QtCore, QtGui, QtWidgets
|
||||
|
||||
@@ -157,7 +156,7 @@ class SettingsDialog(QtWidgets.QDialog, Ui_Dialog):
|
||||
# Logging
|
||||
self.combo_logging.currentTextChanged.connect(self.settings_changed_callback)
|
||||
self.pb_open_log.clicked.connect(
|
||||
lambda: webbrowser.open(logger.root.handlers[0].baseFilename)
|
||||
lambda: open_file(logger.root.handlers[0].baseFilename)
|
||||
)
|
||||
|
||||
# Fonts
|
||||
|
||||
@@ -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])
|
||||
|
||||
Reference in New Issue
Block a user