8000 Add menu commands to open tdm.cfg and log location (#230) · useful-esp8266-lib/tdm@a98adf8 · GitHub
[go: up one dir, main page]

Skip to content

Commit a98adf8

Browse files
authored
Add menu commands to open tdm.cfg and log location (jziolkowski#230)
1 parent e5e17dd commit a98adf8

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

tdmgr.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
import re
88
import sys
99
from json import loads
10+
from logging.handlers import TimedRotatingFileHandler
1011

11-
from PyQt5.QtCore import QDir, QSettings, QSize, Qt, QTimer, QUrl, pyqtSlot
12+
from PyQt5.QtCore import QDir, QFileInfo, QSettings, QSize, Qt, QTimer, QUrl, pyqtSlot
1213
from PyQt5.QtGui import QDesktopServices, QFont, QIcon
1314
from PyQt5.QtWidgets import (
1415
QAction,
@@ -42,8 +43,6 @@
4243
)
4344
from Util.mqtt import MqttClient
4445

45-
# TODO: rework device export
46-
4746
__version__ = "0.3&quo 10000 t;
4847
__tasmota_minimum__ = "6.6.0.17"
4948

@@ -73,12 +72,13 @@ def __init__(
7372

7473
# configure logging
7574
logging.basicConfig(
76-
filename=log_path,
7775
level="DEBUG" if debug else "INFO",
7876
datefmt="%Y-%m-%d %H:%M:%S",
7977
format="%(asctime)s [%(levelname)s] %(message)s",
8078
)
81-
logging.getLogger().addHandler(logging.StreamHandler(sys.stdout))
79+
logging.getLogger().addHandler(
80+
TimedRotatingFileHandler(filename=log_path, when="d", interval=1)
81+
)
8282
logging.info("### TDM START ###")
8383

8484
# load devices from the devices file, create TasmotaDevices and add the to the environment
@@ -185,9 +185,9 @@ def build_mainmenu(self):
185185
mSettings.addAction(QIcon(), "BSSId aliases", self.bssid)
186186
mSettings.addSeparator()
187187
mSettings.addAction(QIcon(), "Preferences", self.prefs)
188-
189-
# mExport = self.menuBar().addMenu("Export")
190-
# mExport.addAction(QIcon(), "OpenHAB", self.openhab)
188+
mSettings.addSeparator()
189+
mSettings.addAction(QIcon(), "Open config file", self.open_config_file)
190+
mSettings.addAction(QIcon(), "Open log file location", self.open_log_location)
191191

192192
def build_toolbars(self):
193193
main_toolbar = Toolbar(
@@ -522,6 +522,14 @@ def prefs(self):
522522

523523
self.settings.sync()
524524

525+
def open_config_file(self):
526+
QDesktopServices.openUrl(QUrl.fromLocalFile(self.settings.fileName()))
527+
528+
@staticmethod
529+
def open_log_location():
530+
fi = QFileInfo(logging.getLogger().handlers[1].baseFilename)
531+
QDesktopServices.openUrl(QUrl.fromLocalFile(fi.absolutePath()))
532+
525533
def auto_telemetry_period(self):
526534
curr_val = self.settings.value("autotelemetry", 5000, int)
527535
period, ok = QInputDialog.getInt(

0 commit comments

Comments
 (0)
0