SPB Git

Repository Public

run.py 5.3 KB 138 lines python

1#!/usr/bin/env python32# =============================================================================3#                  SP BOUCHER | SOFTWARE & RESEARCH4#             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# PROJECT METADATA8# -----------------------------------------------------------------------------9# Project          : Food·Ka10# File             : run.py11# Description      : Utilisation : python run.py sync [source ...] #12#                    synchronise les produits python run.py watch [minutes] #13#                    synchronise en boucle (défaut 360 min) python run.py serve14#                    [port] # démarre l'API + le frontend (défaut 8080)15# Repository       : https://git.spboucher.ai/food-ka16# Created          : 2026-08-1217# Last Modified    : 2026-08-1218#19# =============================================================================20# AUTHOR & PROFESSIONAL AFFILIATION21# =============================================================================22#23# Author           : Simon-Pierre Boucher24# Position         : Professor of Finance25# Institution      : Université du Québec en Outaouais (UQO)26# Department       : Département des sciences administratives27# Organization     : SP Boucher28#29# Website          : https://spboucher.ai30# Git              : https://git.spboucher.ai31#32# =============================================================================33# OFFICIAL CONTACT DIRECTORY34# =============================================================================35#36# General          : info@spboucher.ai37# Professional     : contact@spboucher.ai38# Direct           : simon@spboucher.ai39# Research         : research@spboucher.ai40# Development      : dev@spboucher.ai41# Support          : support@spboucher.ai42# Security/Admin   : admin@spboucher.ai43# Notifications    : notifications@spboucher.ai44#45# Preferred Contact: contact@spboucher.ai46#47# =============================================================================48# COPYRIGHT & INTELLECTUAL PROPERTY49# =============================================================================50#51# Copyright (c) 202652# Simon-Pierre Boucher53#54# All rights reserved where applicable.55#56# This file is governed by the applicable project license,57# copyright notices, institutional agreements and relevant law.58#59# Unless expressly authorized by the applicable license or60# rights holder, copying, redistribution, sublicensing,61# publication and commercial exploitation are not permitted.62#63# Existing third-party rights and notices remain unaffected.64#65# =============================================================================66# CONFIDENTIALITY & SECURITY67# =============================================================================68#69# Classification   : Public70# Distribution     : Public repository; use is governed by the project license71# Security Contact : admin@spboucher.ai72#73# Access to this source does not independently grant permission74# to redistribute or disclose confidential materials.75#76# Do not embed credentials, private keys, access tokens,77# certificates or confidential personal information.78#79# =============================================================================80# LICENSE & MAINTENANCE81# =============================================================================82#83# License          : None specified (no license file in this repository)84# Maintainer       : Simon-Pierre Boucher85# Technical Contact: dev@spboucher.ai86#87# =============================================================================88# END OF SP BOUCHER SOURCE HEADER89# =============================================================================9091# -----------------------------------------------------------------------------92# Food-Ka — Agrégateur de produits d'épicerie (province de Québec)93# Auteur : Simon-Pierre Boucher — contact@spboucher.ai94# run.py : point d'entrée — `sync`, `watch`, `serve`95# -----------------------------------------------------------------------------96"""Utilisation :97    python run.py sync [source ...]     # synchronise les produits98    python run.py watch [minutes]       # synchronise en boucle (défaut 360 min)99    python run.py serve [port]          # démarre l'API + le frontend (défaut 8080)100"""101from __future__ import annotations102103import os104import sys105from pathlib import Path106107# Charger .env (SCRAPFLY_API_KEY, FIRECRAWL_API_KEY…) sans dépendance externe108_env = Path(__file__).parent / ".env"109if _env.exists():110    for line in _env.read_text().splitlines():111        line = line.strip()112        if line and not line.startswith("#") and "=" in line:113            k, _, v = line.partition("=")114            os.environ.setdefault(k.strip(), v.strip())115116117def main() -> None:118    cmd = sys.argv[1] if len(sys.argv) > 1 else "serve"119    if cmd == "sync":120        from foodka import ingest121        ingest.run(sys.argv[2:] or None)122    elif cmd == "watch":123        from foodka import ingest124        minutes = int(sys.argv[2]) if len(sys.argv) > 2 else 360125        ingest.watch(minutes * 60)126    elif cmd == "serve":127        import uvicorn128        port = int(sys.argv[2]) if len(sys.argv) > 2 else 8080129        uvicorn.run("foodka.web:app", host="0.0.0.0", port=port,130                    proxy_headers=True, forwarded_allow_ips="*")131    else:132        print(__doc__)133        sys.exit(1)134135136if __name__ == "__main__":137    main()138
Files main
Menu

Theme