Files
MoFin/deploy/profile-scripts/closing_brief.py
T

44 lines
1.1 KiB
Python

#!/usr/bin/env python3
"""Wrapper script: generates closing brief report.
Calls generate_report.py with the 'closing_brief' argument.
Hermes cron runner does not support script arguments, so this wrapper
is needed to work around that limitation.
"""
import sys
import subprocess
from pathlib import Path
# ── 消息通道统一路由(broadcast/xmpp by delivery) ──
try:
from messenger import install_stdio_hook as _msh
_msh()
except Exception:
pass
script_dir = Path(__file__).parent.resolve()
target = script_dir / "generate_report.py"
if not target.exists():
print(f"ERROR: generate_report.py not found at {target}", file=sys.stderr)
sys.exit(1)
result = subprocess.run(
[sys.executable, str(target), "closing_brief"],
capture_output=True,
text=True,
timeout=120,
)
if result.stdout:
print(result.stdout.strip())
if result.returncode != 0:
error_msg = f"Script exited with code {result.returncode}"
if result.stderr:
error_msg += f"\nstderr:\n{result.stderr}"
print(error_msg, file=sys.stderr)
sys.exit(result.returncode)
if result.stderr:
print(f"stderr:\n{result.stderr}", file=sys.stderr)