#!/usr/bin/env python3 # ----------------------------------------------------------------------------- # Auto-Ka — Agrégateur de voitures usagées à vendre (province de Québec) # Auteur : Simon-Pierre Boucher — contact@spboucher.ai # run.py : point d'entrée — `sync`, `watch`, `serve` # ----------------------------------------------------------------------------- """Utilisation : python run.py sync [source ...] # synchronise les annonces python run.py watch [minutes] # synchronise en boucle (défaut 120 min) python run.py serve [port] # démarre l'API + le frontend (défaut 8080) """ from __future__ import annotations import os import sys from pathlib import Path # Charger .env (FIRECRAWL_API_KEY, etc.) sans dépendance externe _env = Path(__file__).parent / ".env" if _env.exists(): for line in _env.read_text().splitlines(): line = line.strip() if line and not line.startswith("#") and "=" in line: k, _, v = line.partition("=") os.environ.setdefault(k.strip(), v.strip()) def main() -> None: cmd = sys.argv[1] if len(sys.argv) > 1 else "serve" if cmd == "sync": from autoka import ingest ingest.run(sys.argv[2:] or None) elif cmd == "watch": from autoka import ingest minutes = int(sys.argv[2]) if len(sys.argv) > 2 else 120 ingest.watch(minutes * 60) elif cmd == "serve": import uvicorn port = int(sys.argv[2]) if len(sys.argv) > 2 else 8080 uvicorn.run("autoka.web:app", host="0.0.0.0", port=port) else: print(__doc__) sys.exit(1) if __name__ == "__main__": main()