78 lines
2.3 KiB
Python
78 lines
2.3 KiB
Python
"""Create a Gmail draft for client delivery (manual/retry use).
|
|
|
|
Usage:
|
|
uv run python scripts/create_client_draft.py --company "McCormick Industries" \\
|
|
--files data/generated/press_releases/mccormick/file1.docx \\
|
|
--task-id abc123 --type "Press Release"
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import logging
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv()
|
|
|
|
from cheddahbot.config import load_config # noqa: E402
|
|
from cheddahbot.delivery import deliver_to_client # noqa: E402
|
|
|
|
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description="Create client delivery draft email")
|
|
parser.add_argument("--company", required=True, help="Company name (must match companies.md)")
|
|
parser.add_argument("--files", nargs="+", required=True, help="Paths to .docx files")
|
|
parser.add_argument("--task-id", required=True, help="ClickUp task ID for tracking")
|
|
parser.add_argument("--type", default="Press Release", help="Task type (default: Press Release)")
|
|
args = parser.parse_args()
|
|
|
|
config = load_config()
|
|
ctx = {"config": config}
|
|
|
|
file_paths = [Path(f) for f in args.files]
|
|
for f in file_paths:
|
|
if not f.exists():
|
|
print("ERROR: File not found: %s" % f)
|
|
sys.exit(1)
|
|
|
|
print("Creating client delivery draft...")
|
|
print(" Company: %s" % args.company)
|
|
print(" Files: %s" % [str(f) for f in file_paths])
|
|
print(" Task ID: %s" % args.task_id)
|
|
print(" Type: %s" % args.type)
|
|
print()
|
|
|
|
result = deliver_to_client(
|
|
files=file_paths,
|
|
company_name=args.company,
|
|
task_id=args.task_id,
|
|
task_type=args.type,
|
|
ctx=ctx,
|
|
)
|
|
|
|
if result.doc_links:
|
|
print("Google Doc links:")
|
|
for link in result.doc_links:
|
|
print(" - %s" % link)
|
|
|
|
if result.draft_id:
|
|
print("\nGmail draft created: %s" % result.draft_id)
|
|
|
|
if result.errors:
|
|
print("\nErrors:")
|
|
for err in result.errors:
|
|
print(" - %s" % err)
|
|
|
|
print("\nDone." if result.success else "\nCompleted with issues.")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|