Technician tool v0.6

Imported from the Google Drive folder 004-technician_tool/v0.6.
This commit is contained in:
kkallas committed 2026-09-28 17:31:03 +02:00
1 parent f5b32e1554
commit 22bd853ecf
30 files changed
+1521 -568

No files matched your search

+24 -7
View File
@@ -7,7 +7,6 @@ from pathlib import Path
from PySide6.QtCore import QObject, QSettings, Qt, Signal
from PySide6.QtWidgets import (
QApplication,
QCheckBox,
QFileDialog,
QFormLayout,
@@ -34,6 +33,7 @@ DEFAULT_TEMPLATE = Path(__file__).resolve().parents[4] / "002-SD_card_format" /
class _Bridge(QObject):
done = Signal(object)
listed = Signal(object)
def _secret_field() -> tuple[QLineEdit, QCheckBox]:
@@ -52,6 +52,7 @@ class SdTab(QWidget):
self._settings = QSettings("KOTA", "TechnicianTool")
self._cards: list[Disk] = []
self._busy = False
self._listing = False
# --- 1. settings
sbox = QGroupBox("1. Settings written to the card (ENV.TXT)")
@@ -135,6 +136,7 @@ class SdTab(QWidget):
self._bridge = _Bridge()
self._bridge.done.connect(self._on_done)
self._bridge.listed.connect(self._on_listed)
for w in (self.url, self.token, self.ssid, self.password):
w.textChanged.connect(self._update)
self.wifi_box.toggled.connect(self._update)
@@ -199,13 +201,28 @@ class SdTab(QWidget):
super().showEvent(event)
def refresh_cards(self) -> None:
if self._busy:
"""List cards in the background: the UI never waits for a slow card reader."""
if self._busy or self._listing:
return
self._listing = True
self.others.setText("Looking for SD cards...")
def worker():
try:
result = list_cards()
except Exception as exc: # show it, never leave the tab stuck
result = ([], [], str(exc))
self._bridge.listed.emit(result)
threading.Thread(target=worker, daemon=True, name="sd-list").start()
def _on_listed(self, result) -> None:
self._listing = False
self._cards, others = result[0], result[1]
if len(result) > 2:
self.others.setText(f"Could not list cards: {result[2]}")
self._update()
return
QApplication.setOverrideCursor(Qt.CursorShape.WaitCursor)
try:
self._cards, others = list_cards()
finally:
QApplication.restoreOverrideCursor()
self.card_list.clear()
for d in self._cards:
self.card_list.addItem(QListWidgetItem(d.label))