fix: import config depuis core/executor + auto-load config.txt dans run_agent_v1
- 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>
This commit is contained in:
@@ -463,7 +463,7 @@ class ActionExecutorV1:
|
|||||||
retourne les coordonnées.
|
retourne les coordonnées.
|
||||||
"""
|
"""
|
||||||
import requests as _requests
|
import requests as _requests
|
||||||
from .config import API_TOKEN
|
from ..config import API_TOKEN
|
||||||
|
|
||||||
url = f"{server_url}/traces/stream/replay/resolve_target"
|
url = f"{server_url}/traces/stream/replay/resolve_target"
|
||||||
payload = {
|
payload = {
|
||||||
@@ -981,7 +981,7 @@ Example: x_pct=0.50, y_pct=0.30"""
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
# Essayer la détection popup via le serveur d'abord
|
# 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:
|
if SERVER_URL:
|
||||||
monitor = self.sct.monitors[1]
|
monitor = self.sct.monitors[1]
|
||||||
sw, sh = monitor["width"], monitor["height"]
|
sw, sh = monitor["width"], monitor["height"]
|
||||||
|
|||||||
@@ -7,10 +7,43 @@ current_dir = os.path.dirname(os.path.abspath(__file__))
|
|||||||
if current_dir not in sys.path:
|
if current_dir not in sys.path:
|
||||||
sys.path.append(current_dir)
|
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:
|
try:
|
||||||
from agent_v1.main import main
|
from agent_v1.main import main
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
|
logging.error("Erreur d'importation : %s", e)
|
||||||
print(f"Erreur d'importation : {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)
|
||||||
|
|||||||
Reference in New Issue
Block a user