From 23cc2915b8cc80c8fca9f9be17c92814a3cd1e3f Mon Sep 17 00:00:00 2001 From: lvps Date: Wed, 16 Oct 2024 18:42:22 +0200 Subject: [PATCH 1/2] Update lint.yml New Python so the CI is actually able to run --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a4d7926..85dd8f1 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -17,7 +17,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v1 with: - python-version: 3.8 + python-version: 3.12 - name: Install Python dependencies run: pip install black From ad357f4818ae4fa8a5eebb750462c297b9a48f0a Mon Sep 17 00:00:00 2001 From: Lint Action <95386651+weee-open-bot@users.noreply.github.com> Date: Wed, 16 Oct 2024 16:42:37 +0000 Subject: [PATCH 2/2] Fix code style issues with Black --- pinolo.py | 32 +++++++++++++++----------------- widgets/smart.py | 32 ++++++++++---------------------- 2 files changed, 25 insertions(+), 39 deletions(-) diff --git a/pinolo.py b/pinolo.py index c647c0c..45480eb 100644 --- a/pinolo.py +++ b/pinolo.py @@ -518,9 +518,7 @@ def show_smart_data(self): else: self.selected_drive = self.selected_drive.text() if self.selected_drive in self.smart_results: - self.smart_widgets[self.selected_drive] = SmartWidget(self.selected_drive, - self.smart_results[self.selected_drive] - ) + self.smart_widgets[self.selected_drive] = SmartWidget(self.selected_drive, self.smart_results[self.selected_drive]) self.smart_widgets[self.selected_drive].close_signal.connect(self.remove_smart_widget) except BaseException as exc: @@ -565,10 +563,10 @@ def cannolo(self, std=False, drives=None): def upload_to_tarallo_selection(self, std: bool = False): # TODO: check if it's really working - #for row in self.get_selected_drive_rows(): - #if row[1] == "": - # self.upload_to_tarallo(row[0]) - #self.selected_drive = self.selected_drive.text(); + # for row in self.get_selected_drive_rows(): + # if row[1] == "": + # self.upload_to_tarallo(row[0]) + # self.selected_drive = self.selected_drive.text(); self.selected_drive = self.diskTable.item(self.diskTable.currentRow(), 0) if not std: @@ -581,7 +579,7 @@ def upload_to_tarallo_selection(self, std: bool = False): return elif self.diskTable.item(self.diskTable.currentRow(), 1).text() != "": return - loc, ok = input_dialog("Location"); + loc, ok = input_dialog("Location") # If no location is provided or cancel is selected, # cancel the operation @@ -834,7 +832,7 @@ def gui_update(self, cmd: str, params: str): print(f"GUI: Ignored exception while parsing {cmd}, expected JSON but this isn't: {params}") match cmd: - case 'queue_status' | 'get_queue': + case "queue_status" | "get_queue": if cmd == "queue_status": params = [params] for param in params: @@ -891,7 +889,7 @@ def gui_update(self, cmd: str, params: str): if "text" in param: status_cell.setToolTip(param["text"]) - case 'get_disks': + case "get_disks": drives = params if len(drives) <= 0: self.diskTable.setRowCount(0) @@ -903,10 +901,10 @@ def gui_update(self, cmd: str, params: str): self.diskTable.resizeColumnToContents(0) self.diskTable.resizeColumnToContents(1) - case 'smartctl' | 'queued_smartctl': + case "smartctl" | "queued_smartctl": self.smart_results[params["disk"]] = {"output": params["output"], "status": params["status"]} - case ' connection_failed': + case " connection_failed": message = params["reason"] if not self.remoteMode: print("GUI: Connection Failed: Local server not running.") @@ -917,15 +915,15 @@ def gui_update(self, cmd: str, params: str): message = "Cannot find BASILICO server.\nCheck if it's running in the " "targeted machine." warning_dialog(message, dialog_type="ok") - case 'connection_lost': + case "connection_lost": self.statusBar().showMessage(f"⚠ Connection lost. Press the reload button to reconnect.") self.queueTable.setRowCount(0) self.diskTable.setRowCount(0) - case 'connection_made': + case "connection_made": self.statusBar().showMessage(f"Connected to {params['host']}:{params['port']}") - case 'list_iso': + case "list_iso": self.dialog = CannoloDialog(self.settingsDialog, PATH, params) if self.manual_cannolo: self.dialog.update.connect(self.use_cannolo_img) @@ -933,13 +931,13 @@ def gui_update(self, cmd: str, params: str): else: self.dialog.update.connect(self.settingsDialog.set_default_cannolo) - case 'error': + case "error": message = f"{params['message']}" if "command" in params: message += f":\n{params['command']}" critical_dialog(message, dialog_type="ok") - case 'error_that_can_be_manually_fixed': + case "error_that_can_be_manually_fixed": message = params["message"] warning_dialog(message, dialog_type="ok") diff --git a/widgets/smart.py b/widgets/smart.py index 73d5f42..d0f6699 100644 --- a/widgets/smart.py +++ b/widgets/smart.py @@ -4,13 +4,7 @@ from typing import Any, Iterable, List, Dict, Union from PyQt5 import uic from PyQt5.QtCore import pyqtSignal, QAbstractItemModel, QModelIndex, QObject, Qt, QFileInfo -from PyQt5.QtWidgets import ( - QWidget, - QPushButton, - QTreeView, - QLineEdit, - QTreeWidget -) +from PyQt5.QtWidgets import QWidget, QPushButton, QTreeView, QLineEdit, QTreeWidget class SmartWidget(QWidget): @@ -43,9 +37,9 @@ def setup(self): # status line setup self.statusLineEdit.setText(self.smart_status) match self.smart_status: - case 'ok': + case "ok": self.statusLineEdit.setStyleSheet("background-color: green; color: black;") - case 'old': + case "old": self.statusLineEdit.setStyleSheet("background-color: yellow; color: black;") case _: self.statusLineEdit.setStyleSheet("background-color: red; color: black;") @@ -119,9 +113,7 @@ def value_type(self, value): self._value_type = value @classmethod - def load( - cls, value: Union[List, Dict], parent: "TreeItem" = None, sort=True - ) -> "TreeItem": + def load(cls, value: Union[List, Dict], parent: "TreeItem" = None, sort=True) -> "TreeItem": """Create a 'root' TreeItem from a nested list or a nested dictonary Examples: @@ -161,7 +153,7 @@ def load( class JsonModel(QAbstractItemModel): - """ An editable model of Json data """ + """An editable model of Json data""" def __init__(self, parent: QObject = None): super().__init__(parent) @@ -170,7 +162,7 @@ def __init__(self, parent: QObject = None): self._headers = ("key", "value") def clear(self): - """ Clear data from the model """ + """Clear data from the model""" self.load({}) def load(self, document: dict): @@ -180,9 +172,7 @@ def load(self, document: dict): document (dict): JSON-compatible dictionary """ - assert isinstance( - document, (dict, list, tuple) - ), "`document` must be of dict, list or tuple, " f"not {type(document)}" + assert isinstance(document, (dict, list, tuple)), "`document` must be of dict, list or tuple, " f"not {type(document)}" self.beginResetModel() @@ -199,8 +189,8 @@ def clean_document_from_bloat(self, document: dict): for key in IGNORE_SMART_RESULTS: document.pop(key, None) - if 'ata_smart_attributes' in document: - attributes = {} + if "ata_smart_attributes" in document: + attributes = {} for key in document["ata_smart_attributes"]["table"]: attributes[key["name"]] = key["value"] document.pop("ata_smart_attributes", None) @@ -254,9 +244,7 @@ def setData(self, index: QModelIndex, value: Any, role: Qt.ItemDataRole): return False - def headerData( - self, section: int, orientation: Qt.Orientation, role: Qt.ItemDataRole - ): + def headerData(self, section: int, orientation: Qt.Orientation, role: Qt.ItemDataRole): """Override from QAbstractItemModel For the JsonModel, it returns only data for columns (orientation = Horizontal)