refactor(gateway-cli): dispatch-table subcommands and shared service helpers in hermes_cli/gateway.py
hermes_cli/gateway.py (9178 -> 6906): - `hermes gateway` subcommand routing: if/elif chain -> _GATEWAY_SUBCOMMANDS dispatch table of _cmd_* handlers; _stop_installed_service and _refuse_from_inside_gateway unify the stop/restart/uninstall service-stop and self-target guards. - One systemd unit template; _systemctl_show, systemctl reset+action, is-active probes, _installed_service_kind ladder (3 sites), launchctl-list PID probe, launchd bootstrap+kickstart helper, legacy-unit removal loop, loop-tick witness ping, ps/wmic line parsers, planned-stop marker helper, _CAPTURE_TEXT subprocess kwargs (21 sites), _gw_windows() accessor (15 lazy imports). - run_gateway startup helpers, reaper exclusion set, Windows process listing extracted; wizard service actions and platform-setup prompts unified (_setup_service_action). - Dead: _windows_scheduled_task_running (test-only), _container_systemd_operational (inlined), whatsapp/email/matrix built-in status branches (those platforms are registry plugins). - try/except-pass around single statements -> contextlib.suppress; comments/docstrings compacted to the WHY (bounded_probe_run vs subprocess.run on Windows, pythonw launcher-stub filtering, raw-record vs validated-probe exclusion in the orphan reaper, Scheduled-Task Ready-vs-Running). - `hermes gateway --help` byte-identical.
This commit is contained in:
+1763
-4035
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,7 @@
|
||||
"""Tests for hermes_cli.gateway."""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
import textwrap
|
||||
@@ -1089,7 +1087,6 @@ class TestWindowsScheduledTaskSupervisorGuard:
|
||||
raise AssertionError("subprocess must not run off Windows")
|
||||
|
||||
monkeypatch.setattr(gateway.subprocess, "run", _boom_run)
|
||||
assert gateway._windows_scheduled_task_running("HermesGateway") is False
|
||||
assert gateway._windows_scheduled_task_supervises("HermesGateway") is False
|
||||
assert gateway._windows_scheduled_task_state("HermesGateway") is None
|
||||
|
||||
@@ -1100,7 +1097,6 @@ class TestWindowsScheduledTaskSupervisorGuard:
|
||||
for state, expected in states.items():
|
||||
monkeypatch.setattr(gateway, "_windows_scheduled_task_state", lambda name, s=state: s)
|
||||
assert gateway._windows_scheduled_task_supervises("Hermes_Gateway") is expected, state
|
||||
assert gateway._windows_scheduled_task_running("Hermes_Gateway") is (state == "Running")
|
||||
|
||||
|
||||
def test_find_windows_gateway_services_maps_verified_pid_tree(monkeypatch):
|
||||
|
||||
Reference in New Issue
Block a user