diff options
| author | historia <historiavg@proton.me> | 2026-09-01 14:32:05 -0400 |
|---|---|---|
| committer | historia <historiavg@proton.me> | 2026-09-01 14:32:05 -0400 |
| commit | 6cfcd564c0684c52618235e6366f4a81c02b9a5b (patch) | |
| tree | 55321760a8103bc6b5d79489fac4135a60e6e3ba /app/backends/audiocpp/status.py | |
| parent | dc6e7cd43029da62dabe2513fb5aa8a34df1bd6d (diff) | |
| download | tts-audiobook-generator-6cfcd564c0684c52618235e6366f4a81c02b9a5b.tar.gz | |
slop refactor/dedup
Diffstat (limited to 'app/backends/audiocpp/status.py')
| -rw-r--r-- | app/backends/audiocpp/status.py | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/app/backends/audiocpp/status.py b/app/backends/audiocpp/status.py index 9ccf8cc..a687066 100644 --- a/app/backends/audiocpp/status.py +++ b/app/backends/audiocpp/status.py @@ -54,16 +54,20 @@ def detect() -> BackendStatus: launch = format_launch_hint(specs) managed = servers.manages(specs) remote_running, remote_urls = _detect_remote(managed) + running = managed or remote_running # A more specific "part-way set up" label than unavailable/installed: - # cloned but never built, or built but not configured. + # cloned but never built, or built but not configured. Only meaningful + # while the backend is not usable (a running server makes even a + # non-built checkout usable remotely — see the BackendStatus docstring). partial = "" - if not built: - partial = "downloaded (not built)" - elif not configured: - partial = "built (not configured)" + if not running: + if not built: + partial = "downloaded (not built)" + elif not configured: + partial = "built (not configured)" return BackendStatus("audiocpp", "audio.cpp", installed=built, configured=configured, - running=managed or remote_running, + running=running, details=details, launch_hint=launch, servers=specs, managed=managed, remote=remote_running, remote_urls=remote_urls, @@ -73,18 +77,12 @@ def detect() -> BackendStatus: def _detect_remote(managed: bool = False) -> Tuple[bool, dict]: """Detect an externally-run audiocpp_server at the remote URL. - Returns ``(running, {spec_name: url})``. The remote URL is probed only - when configured (non-empty); a server answering there is ignored when it - is this tool's own managed server (remote URL == local URL and our pid is - still alive) — that instance is already reported as "[local]". + Returns ``(running, {spec_name: url})``; see probe.detect_remote_url + for the shared semantics. """ - url = (config.AUDIOCPP_REMOTE_URL or "").strip() - if not url: - return False, {} - if managed and probe.same_endpoint(url, config.AUDIOCPP_API_URL): - return False, {} - if probe.identify_server(url) == probe.IDENTITY_AUDIOCPP: - return True, {"audiocpp": url} - return False, {} + return probe.detect_remote_url(config.AUDIOCPP_REMOTE_URL, + config.AUDIOCPP_API_URL, + probe.IDENTITY_AUDIOCPP, "audiocpp", + managed) |
