mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-27 07:05:23 -04:00
fix(hwfit): repair remote Windows hardware scan over SSH (#4674)
Remote Cookbook hwfit probes failed on Windows hosts because the PowerShell script was sent as nested -Command quoting through OpenSSH. Use -EncodedCommand for remote probes, auto-detect platform when omitted (including Darwin for Mac SSH hosts), and return a clearer error when SSH works but the probe fails. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -72,3 +72,50 @@ def test_gguf_alternate_still_recommended_on_windows():
|
||||
still appear on Windows even though the AWQ variant is hidden."""
|
||||
names = {r["name"] for r in rank_models(_windows_system(), limit=900)}
|
||||
assert "Qwen/Qwen2.5-3B-Instruct" in names
|
||||
|
||||
|
||||
def test_remote_windows_probe_uses_encoded_command(monkeypatch):
|
||||
"""Remote Windows hwfit must not use nested -Command quoting over SSH."""
|
||||
from services.hwfit import hardware
|
||||
|
||||
calls = []
|
||||
monkeypatch.setattr(hardware, "_remote_host", "user@winpc")
|
||||
monkeypatch.setattr(hardware, "_remote_port", None)
|
||||
|
||||
def fake_run(cmd):
|
||||
calls.append(cmd)
|
||||
if isinstance(cmd, str) and "EncodedCommand" in cmd:
|
||||
return (
|
||||
'{"ram_gb":64,"avail_gb":32,"cpu_name":"Test CPU",'
|
||||
'"cpu_cores":8,"arch":64}'
|
||||
)
|
||||
return None
|
||||
|
||||
monkeypatch.setattr(hardware, "_run", fake_run)
|
||||
result = hardware._detect_windows()
|
||||
assert result is not None
|
||||
assert result["total_ram_gb"] == 64
|
||||
assert len(calls) == 1
|
||||
assert "EncodedCommand" in calls[0]
|
||||
assert '-Command "' not in calls[0]
|
||||
|
||||
|
||||
def test_probe_remote_platform_detects_windows(monkeypatch):
|
||||
from services.hwfit import hardware
|
||||
|
||||
monkeypatch.setattr(hardware, "_run", lambda cmd: "Windows_NT\n")
|
||||
assert hardware._probe_remote_platform() == "windows"
|
||||
|
||||
|
||||
def test_probe_remote_platform_detects_darwin(monkeypatch):
|
||||
from services.hwfit import hardware
|
||||
|
||||
def fake_run(cmd):
|
||||
if cmd == "echo %OS%":
|
||||
return "%OS%"
|
||||
if cmd == ["uname", "-s"]:
|
||||
return "Darwin"
|
||||
raise AssertionError(f"unexpected probe cmd: {cmd!r}")
|
||||
|
||||
monkeypatch.setattr(hardware, "_run", fake_run)
|
||||
assert hardware._probe_remote_platform() == "linux"
|
||||
|
||||
Reference in New Issue
Block a user