refactor(plugins/google_meet): collapse duplicate prints/guards, merge cli imports, join string literals

This commit is contained in:
Teknium
2026-09-02 21:47:11 -07:00
parent 8c1ba7b160
commit c0dcee19e9
8 changed files with 19 additions and 40 deletions
+1 -1
View File
@@ -68,7 +68,7 @@ class ChronosCronScheduler(CronScheduler):
logger.warning("Chronos start() reconcile failed: %s", e)
def stop(self) -> None:
return None
pass
def on_jobs_changed(self) -> None:
try:
+1 -2
View File
@@ -285,8 +285,7 @@ def _sweep_empty_dirs(hermes_home: Path) -> int:
Iterative post-order so parents emptied by child removal are caught."""
removed = 0
stack: List[Tuple[Path, bool]] = [
(top, False) for top in _subdirs(hermes_home, _EMPTY_DIR_PROTECTED_TOP_LEVEL | _EMPTY_DIR_SWEEP_PRUNE_DIRS)
]
(top, False) for top in _subdirs(hermes_home, _EMPTY_DIR_PROTECTED_TOP_LEVEL | _EMPTY_DIR_SWEEP_PRUNE_DIRS)]
while stack:
dirpath, visited = stack.pop()
if visited:
+1 -2
View File
@@ -12,8 +12,7 @@ import logging
import platform
from plugins.google_meet import process_manager as pm
from plugins.google_meet.cli import register_cli as _register_meet_cli
from plugins.google_meet.cli import meet_command as _meet_command
from plugins.google_meet.cli import meet_command as _meet_command, register_cli as _register_meet_cli
from plugins.google_meet.tools import (
MEET_JOIN_SCHEMA, MEET_LEAVE_SCHEMA, MEET_SAY_SCHEMA, MEET_STATUS_SCHEMA, MEET_TRANSCRIPT_SCHEMA,
check_meet_requirements, handle_meet_join, handle_meet_leave, handle_meet_say, handle_meet_status,
+7 -14
View File
@@ -106,8 +106,7 @@ def meet_command(args: argparse.Namespace) -> int:
def _cmd_setup() -> int:
print("google_meet preflight")
print("---------------------")
print("google_meet preflight\n---------------------")
system = platform.system()
system_ok = system in {"Linux", "Darwin"}
@@ -170,8 +169,7 @@ def _cmd_install(*, realtime: bool, assume_yes: bool) -> int:
if subprocess.run(cmd, check=False).returncode != 0:
print(fail_msg)
print("google_meet install")
print("-------------------")
print("google_meet install\n-------------------")
pip_pkgs = ["playwright", "websockets"]
print(f"\n[1/3] pip install: {' '.join(pip_pkgs)}")
@@ -187,9 +185,8 @@ def _cmd_install(*, realtime: bool, assume_yes: bool) -> int:
print("\n[2/3] python -m playwright install chromium")
try:
res = subprocess.run(
[sys.executable, "-m", "playwright", "install", "chromium"], check=False, stdin=subprocess.DEVNULL
)
res = subprocess.run([sys.executable, "-m", "playwright", "install", "chromium"], check=False,
stdin=subprocess.DEVNULL)
if res.returncode != 0:
print(" playwright install failed (may already be installed)")
except Exception as e:
@@ -208,14 +205,12 @@ def _cmd_install(*, realtime: bool, assume_yes: bool) -> int:
["sudo", "apt-get", "install", "-y", "pulseaudio-utils"],
" apt install failed — install pulseaudio-utils manually")
elif system == "Darwin":
have_bh = False
try:
out = subprocess.check_output(
have_bh = "BlackHole" in subprocess.check_output(
["system_profiler", "SPAudioDataType"], text=True, encoding='utf-8', errors='replace',
stdin=subprocess.DEVNULL)
have_bh = "BlackHole" in out
except Exception:
pass
have_bh = False
needs = ([] if have_bh else ["blackhole-2ch"]) + ([] if shutil.which("ffmpeg") else ["ffmpeg"])
if not needs:
print(" BlackHole and ffmpeg already installed.")
@@ -245,9 +240,7 @@ def _cmd_auth() -> int:
path = _auth_state_path()
path.parent.mkdir(parents=True, exist_ok=True)
print("opening Chromium — sign in to Google, then return here and press Enter.")
print(f"saving storage state to: {path}")
print(f"opening Chromium — sign in to Google, then return here and press Enter.\nsaving storage state to: {path}")
try:
with sync_playwright() as pw:
browser = pw.chromium.launch(headless=False)
-2
View File
@@ -84,8 +84,6 @@ def _cmd_ping(args: argparse.Namespace, reg: NodeRegistry) -> int:
except Exception as exc: # noqa: BLE001 — surface any connection error
print(json.dumps({"ok": False, "error": str(exc)}))
return 1
if not isinstance(result, dict):
result = {"result": result}
print(json.dumps({"ok": True, "node": args.name, **result}))
return 0
+1 -1
View File
@@ -40,8 +40,8 @@ def _rpc_say(payload: Dict[str, Any], pm) -> Dict[str, Any]:
active = pm._read_active()
enqueued = False
if active and active.get("out_dir"):
queue = Path(active["out_dir"]) / "say_queue.jsonl"
try:
queue = Path(active["out_dir"]) / "say_queue.jsonl"
queue.parent.mkdir(parents=True, exist_ok=True)
with queue.open("a", encoding="utf-8") as fh:
fh.write(json.dumps({"text": text, "ts": time.time()}) + "\n")
+6 -14
View File
@@ -123,15 +123,9 @@ def status() -> Dict[str, Any]:
if not active:
return dict(_NO_ACTIVE)
pid = int(active.get("pid", 0))
return {
"ok": True,
"alive": _pid_alive(pid),
"pid": pid,
"meetingId": active.get("meeting_id"),
"url": active.get("url"),
"startedAt": active.get("started_at"),
"outDir": active.get("out_dir"),
**(read_json(Path(active.get("out_dir", "")) / "status.json") or {})}
return {"ok": True, "alive": _pid_alive(pid), "pid": pid, "meetingId": active.get("meeting_id"),
"url": active.get("url"), "startedAt": active.get("started_at"), "outDir": active.get("out_dir"),
**(read_json(Path(active.get("out_dir", "")) / "status.json") or {})}
def transcript(last: Optional[int] = None) -> Dict[str, Any]:
@@ -160,8 +154,8 @@ def enqueue_say(text: str) -> Dict[str, Any]:
if not active:
return dict(_NO_ACTIVE)
if active.get("mode") != "realtime":
return {"ok": False, "reason": "active meeting is in transcribe mode — pass mode='realtime' "
"to meet_join to enable agent speech"}
return {"ok": False, "reason": ("active meeting is in transcribe mode — pass mode='realtime' "
"to meet_join to enable agent speech")}
out_dir = Path(active.get("out_dir", ""))
if not out_dir.is_dir():
@@ -171,8 +165,7 @@ def enqueue_say(text: str) -> Dict[str, Any]:
entry = {"id": uuid.uuid4().hex[:12], "text": text}
with queue_path.open("a", encoding="utf-8") as f:
f.write(json.dumps(entry) + "\n")
return {"ok": True, "meetingId": active.get("meeting_id"), "enqueued_id": entry["id"],
"queue_path": str(queue_path)}
return {"ok": True, "meetingId": active.get("meeting_id"), "enqueued_id": entry["id"], "queue_path": str(queue_path)}
def stop(*, reason: str = "requested") -> Dict[str, Any]:
@@ -183,7 +176,6 @@ def stop(*, reason: str = "requested") -> Dict[str, Any]:
pid = int(active.get("pid", 0))
out_dir = active.get("out_dir")
if _pid_alive(pid):
_kill(pid, signal.SIGTERM)
for _ in range(20):
+2 -4
View File
@@ -107,8 +107,7 @@ MEET_TRANSCRIPT_SCHEMA: Dict[str, Any] = {
"name": "meet_transcript",
"description": (
"Read the scraped transcript for the active Meet session. Returns "
"full transcript unless 'last' is set, in which case returns the last "
"N lines only."
"full transcript unless 'last' is set, in which case returns the last N lines only."
),
"parameters": {
"type": "object",
@@ -117,8 +116,7 @@ MEET_TRANSCRIPT_SCHEMA: Dict[str, Any] = {
"type": "integer",
"description": (
"Optional: return only the last N caption lines. Useful "
"for polling during a meeting without re-reading the "
"whole transcript."
"for polling during a meeting without re-reading the whole transcript."
),
"minimum": 1,
},