SPB Git

spb/lou-ka

Public

Lou·Ka — tous les logements à louer du Québec, un seul endroit.

2.3 KB · 63 lines python
1#!/usr/bin/env python32# -----------------------------------------------------------------------------3# Lou-Ka — Agrégateur de logements à louer (province de Québec)4# Auteur : Simon-Pierre Boucher — contact@spboucher.ai5# run.py : point d'entrée — `sync`, `watch`, `serve`6# -----------------------------------------------------------------------------7"""Utilisation :8    python run.py sync [source ...]     # synchronise les annonces9    python run.py watch [minutes]       # synchronise en boucle (défaut 60 min)10    python run.py serve [port]          # démarre l'API + le frontend (défaut 8080)11    python run.py record <source ...>   # enregistre les fixtures de test d'une source12    python run.py geocode [n]           # géocode les annonces sans coordonnées (max n requêtes)13"""14from __future__ import annotations1516import os17import sys18from pathlib import Path1920# Charger .env (FIRECRAWL_API_KEY, etc.) sans dépendance externe21_env = Path(__file__).parent / ".env"22if _env.exists():23    for line in _env.read_text().splitlines():24        line = line.strip()25        if line and not line.startswith("#") and "=" in line:26            k, _, v = line.partition("=")27            os.environ.setdefault(k.strip(), v.strip())282930def main() -> None:31    cmd = sys.argv[1] if len(sys.argv) > 1 else "serve"32    if cmd == "sync":33        from louka import ingest34        ingest.run(sys.argv[2:] or None)35    elif cmd == "watch":36        from louka import ingest37        minutes = int(sys.argv[2]) if len(sys.argv) > 2 else 6038        ingest.watch(minutes * 60)39    elif cmd == "geocode":40        from louka import geocode41        limit = int(sys.argv[2]) if len(sys.argv) > 2 else None42        geocode.run(limit)43    elif cmd == "record":44        from louka import fixtures45        from louka.connectors import CONNECTORS46        targets = sys.argv[2:] or sorted(CONNECTORS)47        for sid in targets:48            try:49                print(f"[lou-ka] record {sid} ... {fixtures.record(sid)}")50            except Exception as exc:51                print(f"[lou-ka] record {sid} ÉCHEC : {exc}", file=sys.stderr)52    elif cmd == "serve":53        import uvicorn54        port = int(sys.argv[2]) if len(sys.argv) > 2 else 808055        uvicorn.run("louka.web:app", host="0.0.0.0", port=port)56    else:57        print(__doc__)58        sys.exit(1)596061if __name__ == "__main__":62    main()63
Files · 3c5c00a8f6cd63c58004cc0f474f2bf2aff80b3f
Menu

Theme