_scan_venv_blockers.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. """Compatibility entry point for historical Desktop venv preflights.
  2. PM stages fresh runtime generations instead of modifying a live venv. Current
  3. Desktop no longer calls this module, but older binaries can load it from an
  4. updated checkout. Keep their JSON protocol without scanning or stopping anything.
  5. """
  6. from __future__ import annotations
  7. import json
  8. import sys
  9. def _is_pausable_gateway(cmdline: str) -> bool:
  10. """Historical post-swap import; preserve the canonical gateway predicate.
  11. Required by tests/compat/old_updater_surface.json even though the Desktop
  12. preflight is retired. An unavailable matcher must still fail closed.
  13. """
  14. try:
  15. from gateway.status import looks_like_gateway_command_line
  16. except Exception:
  17. return False
  18. return looks_like_gateway_command_line(cmdline)
  19. def main() -> None:
  20. """Emit one JSON document for old Desktop callers, without process access."""
  21. if sys.argv[1:2] == ["--terminate-safe"]:
  22. # Old Desktop treats exit 0 as a successful stop without reading stdout.
  23. # A stale preview request must never claim to have stopped a process.
  24. print(json.dumps({
  25. "ok": False,
  26. "error": "Legacy preview termination is retired; no processes were stopped.",
  27. }))
  28. raise SystemExit(1)
  29. print(json.dumps({
  30. "ok": True,
  31. "blocked": False,
  32. "processes": [],
  33. "retired": True,
  34. "message": "Legacy venv preflight is retired; PM stages fresh runtime generations.",
  35. }))
  36. raise SystemExit(0)
  37. if __name__ == "__main__":
  38. main()