diff --git a/agent_v0/agent_v1/core/executor.py b/agent_v0/agent_v1/core/executor.py index 7deca00a8..8c16c4cb5 100644 --- a/agent_v0/agent_v1/core/executor.py +++ b/agent_v0/agent_v1/core/executor.py @@ -463,7 +463,7 @@ class ActionExecutorV1: retourne les coordonnées. """ import requests as _requests - from .config import API_TOKEN + from ..config import API_TOKEN url = f"{server_url}/traces/stream/replay/resolve_target" payload = { @@ -981,7 +981,7 @@ Example: x_pct=0.50, y_pct=0.30""" return False # Essayer la détection popup via le serveur d'abord - from .config import SERVER_URL, API_TOKEN + from ..config import SERVER_URL, API_TOKEN if SERVER_URL: monitor = self.sct.monitors[1] sw, sh = monitor["width"], monitor["height"] diff --git a/agent_v0/run_agent_v1.py b/agent_v0/run_agent_v1.py index ec442f211..08b815bd8 100644 --- a/agent_v0/run_agent_v1.py +++ b/agent_v0/run_agent_v1.py @@ -7,10 +7,43 @@ 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}") - print("Assurez-vous d'être dans le répertoire racine du projet et que agent_v1 est bien un package Python.") +except Exception as e: + logging.error("Erreur fatale : %s", e, exc_info=True)