feat: rebuild app with Qt UI, installer and safer switch sync
- Replace the Tkinter app with a PySide6 UI: sidebar navigation, central profile switcher, autosave, light/dark theme, background tasks with progress and cancel, toasts and a filterable activity log - Split logic into netbox_sync.core (config, NetBox, VMware/Proxmox, VM import, switches) and netbox_sync.ui - Replace the three-dialog import chain with a four-step import wizard; support the global VRF and match VMs per cluster - Expose the previously unreachable VRF/prefix batch tool - Switch sync: no silent LLDP config changes, TOFU host key checks, platform auto-detection, Comware name normalization, fixed AOS-S and Comware LLDP parsing, FQDN/management-IP cable matching, dry-run preview, interface types only set on create - Add PyInstaller onedir spec, Inno Setup installer and build.ps1 - Add pytest suite with an in-memory NetBox fake - Stop tracking the built exe Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
e983791baa
commit
4878275f2a
50 files changed
+7960
-3186
No files matched your search
@@ -0,0 +1,91 @@
|
||||
"""Application entry point."""
|
||||
|
||||
import logging
|
||||
import sys
|
||||
import traceback
|
||||
from logging.handlers import RotatingFileHandler
|
||||
|
||||
from PySide6.QtCore import QLibraryInfo, QLocale, Qt, QTranslator
|
||||
from PySide6.QtGui import QGuiApplication, QIcon
|
||||
from PySide6.QtWidgets import QApplication
|
||||
|
||||
from netbox_sync import APP_NAME, APP_USER_MODEL_ID, APP_VERSION
|
||||
from netbox_sync.core.config import log_dir
|
||||
|
||||
|
||||
def setup_logging():
|
||||
from netbox_sync.ui.tasks import QtLogHandler, log_bus
|
||||
|
||||
root = logging.getLogger("netbox_sync")
|
||||
root.setLevel(logging.DEBUG)
|
||||
root.propagate = False
|
||||
try:
|
||||
folder = log_dir()
|
||||
folder.mkdir(parents=True, exist_ok=True)
|
||||
file_handler = RotatingFileHandler(folder / "netbox-sync.log", maxBytes=2_000_000, backupCount=5,
|
||||
encoding="utf-8")
|
||||
file_handler.setLevel(logging.DEBUG)
|
||||
file_handler.setFormatter(logging.Formatter("%(asctime)s %(levelname)-8s %(name)s: %(message)s"))
|
||||
root.addHandler(file_handler)
|
||||
except OSError:
|
||||
pass
|
||||
root.addHandler(QtLogHandler(log_bus))
|
||||
# Third-party libraries only report problems.
|
||||
for name in ("paramiko", "urllib3", "pyVmomi"):
|
||||
logging.getLogger(name).setLevel(logging.WARNING)
|
||||
logging.getLogger("netbox_sync.app").info("%s %s gestartet", APP_NAME, APP_VERSION)
|
||||
|
||||
|
||||
def install_excepthook(window_getter):
|
||||
def hook(exc_type, exc, tb):
|
||||
details = "".join(traceback.format_exception(exc_type, exc, tb))
|
||||
logging.getLogger("netbox_sync.app").error("Unerwarteter Fehler: %s", exc, exc_info=(exc_type, exc, tb))
|
||||
from netbox_sync.ui import widgets
|
||||
try:
|
||||
widgets.error(window_getter(), "Unerwarteter Fehler",
|
||||
f"{exc}\n\nDie Anwendung läuft weiter. Details stehen im Protokoll.", details)
|
||||
except Exception: # noqa: BLE001
|
||||
sys.__excepthook__(exc_type, exc, tb)
|
||||
sys.excepthook = hook
|
||||
|
||||
|
||||
def main():
|
||||
if sys.platform == "win32":
|
||||
import ctypes
|
||||
try:
|
||||
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(APP_USER_MODEL_ID)
|
||||
except (AttributeError, OSError):
|
||||
pass
|
||||
QGuiApplication.setHighDpiScaleFactorRoundingPolicy(Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)
|
||||
app = QApplication(sys.argv)
|
||||
app.setApplicationName(APP_NAME)
|
||||
app.setApplicationDisplayName(APP_NAME)
|
||||
app.setOrganizationName("NetBox Synchronizer")
|
||||
app.setApplicationVersion(APP_VERSION)
|
||||
app.setStyle("Fusion")
|
||||
translator = QTranslator(app)
|
||||
if translator.load(QLocale(QLocale.German), "qtbase", "_", QLibraryInfo.path(QLibraryInfo.TranslationsPath)):
|
||||
app.installTranslator(translator)
|
||||
|
||||
from netbox_sync.ui.resources import resource_path
|
||||
from netbox_sync.ui.theme import base_font, theme
|
||||
|
||||
app.setFont(base_font())
|
||||
app.setWindowIcon(QIcon(str(resource_path("app.ico"))))
|
||||
setup_logging()
|
||||
theme.apply("system")
|
||||
|
||||
from netbox_sync.ui.main_window import MainWindow
|
||||
|
||||
window = MainWindow()
|
||||
window.apply_theme()
|
||||
hints = QGuiApplication.styleHints()
|
||||
if hasattr(hints, "colorSchemeChanged"):
|
||||
hints.colorSchemeChanged.connect(lambda _scheme: theme.mode == "system" and theme.apply())
|
||||
install_excepthook(lambda: window)
|
||||
window.show()
|
||||
return app.exec()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in new issue
Block a user