SPB Git

spb/fabri-ka Public

Agrégateur de produits québécois — www.fabri-ka.com

HTML 57.9% Python 18.6% TypeScript 15.6% CSS 7.8%
1.8 KB · 52 lines python
Raw Blame History
1#!/usr/bin/env python32# -----------------------------------------------------------------------------3# Fabri-Ka — Agrégateur de produits québécois4# Auteur : Simon-Pierre Boucher — contact@spboucher.ai5# run.py : point d'entrée — `sync`, `watch`, `serve`, `registry`6# -----------------------------------------------------------------------------7"""Utilisation :8    python run.py sync [store_id ...]   # synchronise les catalogues9    python run.py watch [minutes]       # synchronise en boucle (défaut 360 min)10    python run.py serve [port]          # démarre l'API + le frontend (défaut 8090)11    python run.py registry              # reconstruit data/stores.json depuis le pipeline12"""13from __future__ import annotations1415import os16import sys17from pathlib import Path1819_env = Path(__file__).parent / ".env"20if _env.exists():21    for line in _env.read_text().splitlines():22        line = line.strip()23        if line and not line.startswith("#") and "=" in line:24            k, _, v = line.partition("=")25            os.environ.setdefault(k.strip(), v.strip())262728def main() -> None:29    cmd = sys.argv[1] if len(sys.argv) > 1 else "serve"30    if cmd == "sync":31        from fabrika import ingest32        ingest.run(sys.argv[2:] or None)33    elif cmd == "watch":34        from fabrika import ingest35        minutes = int(sys.argv[2]) if len(sys.argv) > 2 else 36036        ingest.watch(minutes * 60)37    elif cmd == "registry":38        sys.path.insert(0, str(Path(__file__).parent / "scripts"))39        import build_registry40        build_registry.main()41    elif cmd == "serve":42        import uvicorn43        port = int(sys.argv[2]) if len(sys.argv) > 2 else 809044        uvicorn.run("fabrika.web:app", host="0.0.0.0", port=port)45    else:46        print(__doc__)47        sys.exit(1)484950if __name__ == "__main__":51    main()52