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
|
|
@ -98,8 +98,8 @@ def render_page(profile):
|
|||
"encoders": [dict(e) for e in raw["encoders"]],
|
||||
})
|
||||
tabs = "".join(
|
||||
f'<a class="tab {"active" if p == profile else ""}" href="/?profile={p}">{html.escape(vp.PROFILE_NAMES[p])}</a>'
|
||||
for p in sorted(vp.PROFILE_NAMES)
|
||||
f'<a class="tab {"active" if p == profile else ""}" href="/?profile={p}">{html.escape(combined["profile_names"][p])}</a>'
|
||||
for p in range(vp.NUM_PROFILES)
|
||||
)
|
||||
cells = "".join(render_cell(b) for b in cfg["buttons"])
|
||||
encoders = "".join(render_encoder(e) for e in cfg["encoders"])
|
||||
|
|
@ -130,7 +130,7 @@ class Handler(BaseHTTPRequestHandler):
|
|||
profile = int(query.get("profile", ["0"])[0])
|
||||
except ValueError:
|
||||
profile = 0
|
||||
if profile not in vp.PROFILE_NAMES:
|
||||
if not (0 <= profile < vp.NUM_PROFILES):
|
||||
profile = 0
|
||||
try:
|
||||
body = render_page(profile).encode("utf-8")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue