Spaces:
Sleeping
Sleeping
Sync from GitHub main β ERP priority, WMCA/Shropshire watchlist, network preserve-owners fix (a7395ea)
a87217c verified Download scripts/send_adhoc_digest.py from mipwr-admin/curium-intel: direct link, hf CLI and curl.
- Browser
- Download file 1.79 kB
-
https://huggingface.co/spaces/mipwr-admin/curium-intel/resolve/main/scripts/send_adhoc_digest.py
- Command line
-
hf download hf://spaces/mipwr-admin/curium-intel/scripts/send_adhoc_digest.py
-
curl -L -o send_adhoc_digest.py https://huggingface.co/spaces/mipwr-admin/curium-intel/resolve/main/scripts/send_adhoc_digest.py
1.79 kB
| """ | |
| Send the full aggregate digest to any ad-hoc email address. | |
| Builds the same cross-team digest that Adela receives (all colleagues' | |
| leads, combined view) and sends it to the specified address. | |
| Usage: | |
| python scripts/send_adhoc_digest.py jodie@example.com "Jodie" | |
| python scripts/send_adhoc_digest.py jodie@example.com # name defaults to address | |
| This is intentionally a thin wrapper β the digest content comes from | |
| build_aggregate_digest() so it stays in sync with whatever the weekly | |
| digest looks like on any given run. | |
| """ | |
| from __future__ import annotations | |
| import sys | |
| from pathlib import Path | |
| REPO_ROOT = Path(__file__).resolve().parent.parent | |
| sys.path.insert(0, str(REPO_ROOT)) | |
| try: | |
| from dotenv import load_dotenv | |
| load_dotenv(REPO_ROOT / ".env", override=False) | |
| except ImportError: | |
| pass | |
| import mailer | |
| import weekly_digest | |
| def main() -> int: | |
| if len(sys.argv) < 2: | |
| print("Usage: send_adhoc_digest.py <email> [name]") | |
| return 1 | |
| to_email = sys.argv[1].strip() | |
| recipient_name = sys.argv[2].strip() if len(sys.argv) > 2 else to_email | |
| print(f"β Building aggregate digest for {recipient_name}β¦") | |
| bundle = weekly_digest.build_aggregate_digest(recipient_name=recipient_name) | |
| print(f" Subject : {bundle['subject']}") | |
| print(f" Leads : {bundle.get('n_leads', '?')}") | |
| print(f"β Sending to {to_email}β¦") | |
| result = mailer.send( | |
| to_email=to_email, | |
| subject=bundle["subject"], | |
| html=bundle["html"], | |
| text_fallback=bundle.get("text_fallback", ""), | |
| ) | |
| if result.get("success"): | |
| print("β Sent") | |
| return 0 | |
| else: | |
| print(f"β Failed: {result.get('message')}") | |
| return 1 | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |