46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
|
|
#!/usr/bin/env python3
|
||
|
|
"""Daily Herman War Room digest → Telegram Aïssa + Mo (runs inside cockpit container)."""
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
import json
|
||
|
|
import subprocess
|
||
|
|
import sys
|
||
|
|
|
||
|
|
|
||
|
|
def main() -> int:
|
||
|
|
code = r"""
|
||
|
|
import asyncio, json
|
||
|
|
from app.services.warroom_digest import run_daily_digest
|
||
|
|
res = asyncio.run(run_daily_digest(hours=24, deliver=True))
|
||
|
|
print(json.dumps({
|
||
|
|
"ok": res.get("ok"),
|
||
|
|
"message_count": res.get("message_count"),
|
||
|
|
"generated_at": res.get("generated_at"),
|
||
|
|
"digest_preview": (res.get("digest") or "")[:600],
|
||
|
|
"deliveries": [
|
||
|
|
{"name": d.get("name"), "ok": d.get("ok"), "confirm": (d.get("confirm") or d.get("error") or "")[:160]}
|
||
|
|
for d in (res.get("deliveries") or [])
|
||
|
|
],
|
||
|
|
}, ensure_ascii=False))
|
||
|
|
"""
|
||
|
|
try:
|
||
|
|
proc = subprocess.run(
|
||
|
|
["docker", "exec", "-i", "foodlinkk_cockpit", "python", "-c", code],
|
||
|
|
capture_output=True,
|
||
|
|
text=True,
|
||
|
|
timeout=360,
|
||
|
|
)
|
||
|
|
except Exception as exc:
|
||
|
|
print("War Room digest failed:", exc, file=sys.stderr)
|
||
|
|
return 1
|
||
|
|
if proc.returncode != 0:
|
||
|
|
print(proc.stdout)
|
||
|
|
print(proc.stderr, file=sys.stderr)
|
||
|
|
return proc.returncode or 1
|
||
|
|
print(proc.stdout.strip())
|
||
|
|
return 0
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
raise SystemExit(main())
|