Move config storage next to the install and auto-create it if missing
versapad_combined.DEFAULT_PATH was hardcoded to this one machine's OneDrive desktop, which made the tool unusable anywhere else. versapad_data.app_dir() now resolves to the running .exe's own folder when frozen, or the project directory when run from source, and DEFAULT_PATH hangs off that instead. load_or_fetch() previously raised when both the file was missing and the board unreachable, blocking a fresh install with no config and no board attached. It now falls back to an empty default_combined() in that case, so the tool is immediately usable either way. desktop_viewer's _current_profile_view() picks up the same fallback instead of re-implementing a narrower version of it. Also drop the hardcoded PROFILE_NAMES dict, which had drifted out of sync with the profile_names already stored in the combined JSON -- renaming a profile in Programmiermodus never showed up in the read-only/browser views. server.py and desktop_viewer.py now read names from the same JSON everywhere. versapad_data.CONFIG_PATHS (read-only interop with the official C# VersaGUI's JSON export) is intentionally left on the OneDrive desktop -- nothing in this codebase writes there, it's not part of this tool's own config.
This commit is contained in:
parent
13c3745479
commit
5d14bdd826
7 changed files with 147 additions and 57 deletions
|
|
@ -7,19 +7,35 @@ Kein Schreibzugriff auf die JSONs -- reines Lesen/Anzeigen.
|
|||
"""
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
NUM_PROFILES = 3
|
||||
|
||||
|
||||
def app_dir():
|
||||
"""Verzeichnis fuer die eigene Config-Datei (versapad_config_all.json,
|
||||
siehe versapad_combined.DEFAULT_PATH): bei der gebauten .exe (--onedir)
|
||||
das Installationsverzeichnis neben der .exe, sonst der Ordner dieses
|
||||
Moduls (Projektordner beim Start aus dem Quellcode). Kein hartkodierter
|
||||
Pfad mehr -- so laesst sich das Tool auf jede Maschine kopieren/
|
||||
installieren, ohne Pfade von Hand anzupassen."""
|
||||
if getattr(sys, "frozen", False):
|
||||
return os.path.dirname(sys.executable)
|
||||
return os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
# CONFIG_PATHS zeigt bewusst weiterhin auf den OneDrive-Desktop -- das sind
|
||||
# keine von diesem Tool geschriebenen Dateien, sondern ein Export der
|
||||
# offiziellen (C#/.NET-)VersaGUI auf dieser einen Maschine (reine Lese-
|
||||
# Interop, siehe README "Bekannte Einschraenkungen"). Fuer das eigentliche,
|
||||
# von diesem Tool selbst gepflegte Format siehe versapad_combined.DEFAULT_PATH
|
||||
# (liegt jetzt in app_dir(), nicht mehr hartkodiert auf dem Desktop).
|
||||
CONFIG_PATHS = {
|
||||
0: os.path.expanduser(r"~\OneDrive\Desktop\versapad_config1.json"),
|
||||
1: os.path.expanduser(r"~\OneDrive\Desktop\versapad_config2.json"),
|
||||
2: os.path.expanduser(r"~\OneDrive\Desktop\versapad_config3.json"),
|
||||
}
|
||||
|
||||
PROFILE_NAMES = {
|
||||
0: "Profil 0 – Windows",
|
||||
1: "Profil 1 – Fusion 360",
|
||||
2: "Profil 2 – BricsCAD",
|
||||
}
|
||||
|
||||
# index = spalte*5 + reihe, Reihe 0 = oben, Reihe 4 = unten (VersaMCU-Firmware-Reihenfolge)
|
||||
GRID_COLS = 4
|
||||
GRID_ROWS = 5
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue