diff --git a/nitrokeyapp/about_dialog.py b/nitrokeyapp/about_dialog.py index 4d484426..f8749567 100644 --- a/nitrokeyapp/about_dialog.py +++ b/nitrokeyapp/about_dialog.py @@ -5,7 +5,6 @@ from nitrokeyapp.logger import save_log from nitrokeyapp.qt_utils_mix_in import QtUtilsMixIn - ## unused ? diff --git a/nitrokeyapp/error_dialog.py b/nitrokeyapp/error_dialog.py index 5b9ab93d..e55d14c1 100644 --- a/nitrokeyapp/error_dialog.py +++ b/nitrokeyapp/error_dialog.py @@ -5,8 +5,8 @@ from PySide6.QtCore import Slot from PySide6.QtWidgets import QDialog, QDialogButtonBox, QPushButton, QWidget -from nitrokeyapp.qt_utils_mix_in import QtUtilsMixIn from nitrokeyapp.logger import save_log +from nitrokeyapp.qt_utils_mix_in import QtUtilsMixIn class ErrorDialog(QtUtilsMixIn, QDialog): diff --git a/nitrokeyapp/gui.py b/nitrokeyapp/gui.py index 7183d697..7d071d1a 100644 --- a/nitrokeyapp/gui.py +++ b/nitrokeyapp/gui.py @@ -69,7 +69,9 @@ def __init__(self, qt_app: QtWidgets.QApplication, log_file: str): self.monitor = pyudev.Monitor.from_netlink(self.context) self.monitor.filter_by(subsystem="usb") # pyudev.pyside6 integration doesn't work properly - self.observer = pyudev.MonitorObserver(self.monitor, lambda action, device: self.sig_device_change.emit(action)) + self.observer = pyudev.MonitorObserver( + self.monitor, lambda action, device: self.sig_device_change.emit(action) + ) self.observer.start() # windows @@ -86,7 +88,7 @@ def __init__(self, qt_app: QtWidgets.QApplication, log_file: str): # loads main ui self.ui = self.load_ui("mainwindow.ui", self) - #self.setCentralWidget(self.ui) + # self.setCentralWidget(self.ui) self.info_box = InfoBox( self.ui.information_frame, @@ -130,7 +132,6 @@ def __init__(self, qt_app: QtWidgets.QApplication, log_file: str): self.sig_device_change.connect(self.device_connect) - self.init_gui() self.show() @@ -138,7 +139,7 @@ def __init__(self, qt_app: QtWidgets.QApplication, log_file: str): self.help_btn.clicked.connect( lambda: webbrowser.open("https://docs.nitrokey.com/nitrokey3") ) - #self.lock_btn.clicked.connect(self.slot_lock_button_pressed) + # self.lock_btn.clicked.connect(self.slot_lock_button_pressed) self.home_button.clicked.connect(self.home_button_pressed) # self.settings_btn.clicked.connect() # connections for functional signals @@ -259,8 +260,8 @@ def refresh(self) -> None: def init_gui(self) -> None: self.tabs.hide() self.info_box.hide() - #self.lock_btn.setEnabled(False) - #self.settings_btn.setEnabled(False) + # self.lock_btn.setEnabled(False) + # self.settings_btn.setEnabled(False) self.detect_added_devices() def device_selected(self, data: DeviceData) -> None: diff --git a/nitrokeyapp/logger.py b/nitrokeyapp/logger.py index a969d99e..f9ecd05e 100644 --- a/nitrokeyapp/logger.py +++ b/nitrokeyapp/logger.py @@ -15,6 +15,7 @@ log_to_console = "NKAPP_LOG" in os.environ + @contextmanager def init_logging() -> Generator[str, None, None]: log_file = NamedTemporaryFile(prefix="nitrokey-app2.", suffix=".log", delete=False) diff --git a/nitrokeyapp/qt_utils_mix_in.py b/nitrokeyapp/qt_utils_mix_in.py index 6a42cc3e..55e2cf26 100644 --- a/nitrokeyapp/qt_utils_mix_in.py +++ b/nitrokeyapp/qt_utils_mix_in.py @@ -1,8 +1,8 @@ -from typing import Optional, Type, TypeVar from pathlib import Path +from typing import Optional, Type, TypeVar from PySide6 import QtGui, QtWidgets -from PySide6.QtCore import QObject, QSize, QDir, QMetaObject +from PySide6.QtCore import QDir, QMetaObject, QObject, QSize from PySide6.QtWidgets import QWidget from nitrokeyapp.ui_loader import UiLoader diff --git a/nitrokeyapp/secrets_tab/__init__.py b/nitrokeyapp/secrets_tab/__init__.py index c936f731..b21deda4 100644 --- a/nitrokeyapp/secrets_tab/__init__.py +++ b/nitrokeyapp/secrets_tab/__init__.py @@ -7,10 +7,11 @@ from nitrokeyapp.add_secret_dialog import AddSecretDialog from nitrokeyapp.device_data import DeviceData -#from nitrokeyapp.ui.secrets_tab import Ui_SecretsTab -from nitrokeyapp.worker import Worker from nitrokeyapp.qt_utils_mix_in import QtUtilsMixIn +# from nitrokeyapp.ui.secrets_tab import Ui_SecretsTab +from nitrokeyapp.worker import Worker + from .data import Credential, OtpData from .worker import SecretsWorker @@ -72,8 +73,8 @@ def __init__(self, parent: Optional[QWidget] = None) -> None: self.originalText = self.clipboard.text() self.ui = self.load_ui("secrets_tab.ui", self) - #breakpoint() - #print(self.pageCompatible) + # breakpoint() + # print(self.pageCompatible) labels = [ self.labelName, diff --git a/nitrokeyapp/ui_loader.py b/nitrokeyapp/ui_loader.py index 35d7819d..c586a3c1 100644 --- a/nitrokeyapp/ui_loader.py +++ b/nitrokeyapp/ui_loader.py @@ -1,5 +1,6 @@ from PySide6.QtUiTools import QUiLoader + # taken/inspired with many thanks from: https://gist.github.com/cpbotha/1b42a20c8f3eb9bb7cb8 class UiLoader(QUiLoader): """ @@ -27,7 +28,7 @@ def __init__(self, baseinstance, customWidgets=None): self.baseinstance = baseinstance self.customWidgets = customWidgets - def createWidget(self, class_name, parent=None, name=''): + def createWidget(self, class_name, parent=None, name=""): """ Function that is called for each widget defined in ui file, overridden here to populate baseinstance instead. @@ -46,7 +47,11 @@ def createWidget(self, class_name, parent=None, name=''): widget = self.customWidgets[class_name](parent) except (TypeError, KeyError) as e: - raise Exception("No custom widget " + class_name + " found in customWidgets param of UiLoader __init__.") + raise Exception( + "No custom widget " + + class_name + + " found in customWidgets param of UiLoader __init__." + ) if self.baseinstance: # set an attribute for the new child widget on the base @@ -56,6 +61,6 @@ def createWidget(self, class_name, parent=None, name=''): # this outputs the various widget names, e.g. # sampleGraphicsView, dockWidget, samplesTableView etc. - #print(name) + # print(name) return widget diff --git a/nitrokeyapp/update.py b/nitrokeyapp/update.py index 4fe306d9..235f4e06 100644 --- a/nitrokeyapp/update.py +++ b/nitrokeyapp/update.py @@ -100,7 +100,8 @@ def confirm_download(self, current: Optional[Version], new: Version) -> None: ) confirm_download_msgBox.setWindowTitle("Nitrokey 3 Firmware Update") confirm_download_msgBox.setStandardButtons( - QtWidgets.QMessageBox.StandardButton.Ok | QtWidgets.QMessageBox.StandardButton.Cancel + QtWidgets.QMessageBox.StandardButton.Ok + | QtWidgets.QMessageBox.StandardButton.Cancel ) returnValue = confirm_download_msgBox.exec() if returnValue == QtWidgets.QMessageBox.StandardButton.Cancel: @@ -122,7 +123,8 @@ def confirm_update(self, current: Optional[Version], new: Version) -> None: ) confirm_update_msgBox.setWindowTitle("Nitrokey 3 Firmware Update") confirm_update_msgBox.setStandardButtons( - QtWidgets.QMessageBox.StandardButton.Ok | QtWidgets.QMessageBox.StandardButton.Cancel + QtWidgets.QMessageBox.StandardButton.Ok + | QtWidgets.QMessageBox.StandardButton.Cancel ) returnValue = confirm_update_msgBox.exec() if returnValue == QtWidgets.QMessageBox.StandardButton.Cancel: @@ -138,13 +140,16 @@ def confirm_update(self, current: Optional[Version], new: Version) -> None: def confirm_update_same_version(self, version: Version) -> None: confirm_update_same_version_msgBox = QtWidgets.QMessageBox(self.overview_tab) - confirm_update_same_version_msgBox.setIcon(QtWidgets.QMessageBox.Icon.Information) + confirm_update_same_version_msgBox.setIcon( + QtWidgets.QMessageBox.Icon.Information + ) confirm_update_same_version_msgBox.setText( "The version of the firmware image is the same as on the device. Do you want to continue anyway?" ) confirm_update_same_version_msgBox.setWindowTitle("Nitrokey 3 Firmware Update") confirm_update_same_version_msgBox.setStandardButtons( - QtWidgets.QMessageBox.StandardButton.Ok | QtWidgets.QMessageBox.StandardButton.Cancel + QtWidgets.QMessageBox.StandardButton.Ok + | QtWidgets.QMessageBox.StandardButton.Cancel ) returnValue = confirm_update_same_version_msgBox.exec() if returnValue == QtWidgets.QMessageBox.StandardButton.Cancel: diff --git a/nitrokeyapp/welcome_tab.py b/nitrokeyapp/welcome_tab.py index 833af88c..5cc23f8e 100644 --- a/nitrokeyapp/welcome_tab.py +++ b/nitrokeyapp/welcome_tab.py @@ -11,7 +11,6 @@ from nitrokeyapp.qt_utils_mix_in import QtUtilsMixIn - class WelcomeTab(QtUtilsMixIn, QWidget): def __init__(self, parent: Optional[QWidget], log_file: str) -> None: QWidget.__init__(self, parent)