SPB Git

Repository Public

run.py 5.5 KB 143 lines python

1#!/usr/bin/env python32# =============================================================================3#                  SP BOUCHER | SOFTWARE & RESEARCH4#             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# PROJECT METADATA8# -----------------------------------------------------------------------------9# Project          : Auto·Ka10# File             : run.py11# Description      : Utilisation : python run.py sync [source ...] #12#                    synchronise les annonces python run.py watch [minutes] #13#                    synchronise en boucle (défaut 120 min) python run.py serve14#                    [port] # démarre l'API + le frontend (défaut 8080)15# Repository       : https://git.spboucher.ai/auto-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# Auto-Ka — Agrégateur de voitures usagées à vendre (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 annonces98    python run.py watch [minutes]       # synchronise en boucle (défaut 120 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 (FIRECRAWL_API_KEY, etc.) 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    # Sous PM2 la sortie standard est un tube : sans ceci Python la met en119    # tampon par blocs et le journal du veilleur paraît figé pendant des heures.120    try:121        sys.stdout.reconfigure(line_buffering=True)122    except (AttributeError, ValueError):123        pass124    cmd = sys.argv[1] if len(sys.argv) > 1 else "serve"125    if cmd == "sync":126        from autoka import ingest127        ingest.run(sys.argv[2:] or None)128    elif cmd == "watch":129        from autoka import ingest130        minutes = int(sys.argv[2]) if len(sys.argv) > 2 else 120131        ingest.watch(minutes * 60)132    elif cmd == "serve":133        import uvicorn134        port = int(sys.argv[2]) if len(sys.argv) > 2 else 8080135        uvicorn.run("autoka.web:app", host="0.0.0.0", port=port)136    else:137        print(__doc__)138        sys.exit(1)139140141if __name__ == "__main__":142    main()143
Files main
Menu

Theme