Warn on an untested cv4pve-cli version at startup
CI / pytest and ruff (pull_request) Successful in 4m42s
CI / pytest and ruff (push) Has been cancelled

At startup the app runs `cv4pve-cli --version`. If it differs from
cli.TESTED_VERSION (2.4.0), a warning says which version was found
and which one was tested. The app parses output formats that are not
a stable API: the config list text, prune-backups as a JSON string,
the CT ip-addresses JSON string and the exit codes with --wait. A
newer cv4pve-cli could break them in confusing ways.

If cv4pve-cli cannot be run at all, an error says so once, instead of
every later call failing without explanation. The README notes the
tested version.

Closes #14

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit was merged in pull request #27.
This commit is contained in:
DuckbootandClaude Opus 5.5 committed 2026-11-03 00:30:14 +01:00
1 parent 364f8e2137
commit e7569a7bf7
5 files changed
+83 -1

No files matched your search

+20
View File
@@ -1040,6 +1040,7 @@ class GuestApp(App):
def on_mount(self) -> None:
# one place for every sub_title change: mount, switch and failed switch
self.watch(self, "sub_title", self._show_context_frame)
self._check_version()
table = self.query_one("#guests", DataTable)
table.add_columns(
"", # "!" = no backup job covers the guest
@@ -1084,6 +1085,25 @@ class GuestApp(App):
self.package_count = count
self._update_frame()
@work(thread=True)
def _check_version(self) -> None:
try:
found = cli.version()
except Exception as exc: # noqa: BLE001 - every later call fails too; say why once
self.call_from_thread(
self.notify,
f"cv4pve-cli is not runnable: {_message(exc)}",
severity="error",
)
return
if found != cli.TESTED_VERSION:
self.call_from_thread(
self.notify,
f"cv4pve-cli {found} found; this app was tested with {cli.TESTED_VERSION}. "
"Some screens may misread its output.",
severity="warning",
)
def _show_context_frame(self, sub_title: str) -> None:
self.context_name = sub_title.removeprefix("context: ")
self._update_frame()
+8
View File
@@ -5,6 +5,10 @@ import json
import re
import subprocess
# Output formats this app parses (config list text, prune-backups as a JSON string, the CT
# ip-addresses JSON string, exit codes with --wait) were verified against this version.
TESTED_VERSION = "2.4.0"
class CliError(Exception):
"""cv4pve-cli failed; str() is its combined, stripped output."""
@@ -472,3 +476,7 @@ def task_log(upid: str) -> str:
if not isinstance(upid, str) or not upid.startswith("UPID:"):
raise ValueError("not a task id (UPID)")
return run("task", "log", upid)
def version() -> str:
return run("--version").strip()