- from .config → from ..config (executor.py est dans core/, config dans agent_v1/) - run_agent_v1.py charge config.txt et .env au démarrage (fonctionne sans Lea.bat) - Ajout file logging dans agent_debug.log pour diagnostic Windows Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
50 lines
2.0 KiB
Python
50 lines
2.0 KiB
Python
# run_agent_v1.py
|
|
import sys
|
|
import os
|
|
|
|
# Ajout du répertoire courant au PYTHONPATH pour permettre les imports de modules
|
|
current_dir = os.path.dirname(os.path.abspath(__file__))
|
|
if current_dir not in sys.path:
|
|
sys.path.append(current_dir)
|
|
|
|
# Charger config.txt et .env comme variables d'environnement
|
|
# (équivalent du `set` dans Lea.bat, mais fonctionne aussi sans le .bat)
|
|
for config_file in ("config.txt", ".env"):
|
|
config_path = os.path.join(current_dir, config_file)
|
|
if os.path.isfile(config_path):
|
|
with open(config_path, encoding="utf-8", errors="ignore") as f:
|
|
for line in f:
|
|
line = line.strip()
|
|
if not line or line.startswith("#"):
|
|
continue
|
|
if "=" in line:
|
|
key, _, value = line.partition("=")
|
|
key = key.strip()
|
|
value = value.strip()
|
|
if key and value and key not in os.environ:
|
|
os.environ[key] = value
|
|
|
|
# Configurer le logging dans un fichier (fonctionne même avec pythonw.exe)
|
|
import logging
|
|
log_path = os.path.join(current_dir, "agent_debug.log")
|
|
logging.basicConfig(
|
|
filename=log_path,
|
|
level=logging.INFO,
|
|
format="%(asctime)s [%(name)s] %(levelname)s: %(message)s",
|
|
)
|
|
logging.info("=== Agent V1 démarrage — config chargée ===")
|
|
logging.info("RPA_SERVER_URL=%s", os.environ.get("RPA_SERVER_URL", "(non défini)"))
|
|
logging.info("RPA_SERVER_HOST=%s", os.environ.get("RPA_SERVER_HOST", "(non défini)"))
|
|
logging.info("RPA_API_TOKEN=%s", os.environ.get("RPA_API_TOKEN", "(non défini)")[:8] + "...")
|
|
logging.info("RPA_BLUR_SENSITIVE=%s", os.environ.get("RPA_BLUR_SENSITIVE", "(non défini)"))
|
|
|
|
try:
|
|
from agent_v1.main import main
|
|
if __name__ == "__main__":
|
|
main()
|
|
except ImportError as e:
|
|
logging.error("Erreur d'importation : %s", e)
|
|
print(f"Erreur d'importation : {e}")
|
|
except Exception as e:
|
|
logging.error("Erreur fatale : %s", e, exc_info=True)
|