- Frontend v4 accessible sur réseau local (192.168.1.40) - Ports ouverts: 3002 (frontend), 5001 (backend), 5004 (dashboard) - Ollama GPU fonctionnel - Self-healing interactif - Dashboard confiance Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
94 lines
2.7 KiB
Python
Executable File
94 lines
2.7 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Script de correction pour l'upload des screenshots manquants.
|
|
|
|
Ce script :
|
|
1. Identifie les sessions avec screenshots non uploadés
|
|
2. Recrée les archives ZIP avec les screenshots inclus
|
|
3. Relance l'upload vers le serveur
|
|
"""
|
|
|
|
import os
|
|
import json
|
|
import zipfile
|
|
from pathlib import Path
|
|
import sys
|
|
|
|
# Ajouter le répertoire agent_v0 au path
|
|
sys.path.insert(0, 'agent_v0')
|
|
|
|
from uploader import upload_session_zip
|
|
|
|
def fix_session_upload(session_dir: Path) -> bool:
|
|
"""
|
|
Corrige l'upload d'une session en incluant les screenshots.
|
|
|
|
Args:
|
|
session_dir: Répertoire de la session
|
|
|
|
Returns:
|
|
True si correction réussie
|
|
"""
|
|
session_id = session_dir.name
|
|
json_file = session_dir / f"{session_id}.json"
|
|
shots_dir = session_dir / "shots"
|
|
|
|
if not json_file.exists():
|
|
print(f"❌ JSON manquant pour {session_id}")
|
|
return False
|
|
|
|
if not shots_dir.exists() or not list(shots_dir.glob("*.png")):
|
|
print(f"⚠️ Pas de screenshots pour {session_id}")
|
|
return False
|
|
|
|
# Créer un nouveau ZIP avec screenshots
|
|
zip_path = session_dir.parent / f"{session_id}_fixed.zip"
|
|
|
|
try:
|
|
with zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED) as zf:
|
|
# Ajouter le JSON
|
|
zf.write(json_file, f"{session_id}.json")
|
|
|
|
# Ajouter tous les screenshots
|
|
for screenshot in shots_dir.glob("*.png"):
|
|
zf.write(screenshot, f"shots/{screenshot.name}")
|
|
|
|
print(f"📦 Archive créée : {zip_path}")
|
|
|
|
# Uploader la nouvelle archive
|
|
if upload_session_zip(str(zip_path), session_id):
|
|
print(f"✅ Upload réussi pour {session_id}")
|
|
# Nettoyer l'archive temporaire
|
|
zip_path.unlink()
|
|
return True
|
|
else:
|
|
print(f"❌ Upload échoué pour {session_id}")
|
|
return False
|
|
|
|
except Exception as e:
|
|
print(f"❌ Erreur création ZIP pour {session_id}: {e}")
|
|
return False
|
|
|
|
def main():
|
|
"""Point d'entrée principal."""
|
|
print("🚀 Correction des uploads de screenshots...")
|
|
|
|
agent_sessions = Path("agent_v0/sessions")
|
|
if not agent_sessions.exists():
|
|
print("❌ Répertoire agent_v0/sessions non trouvé")
|
|
return
|
|
|
|
fixed_count = 0
|
|
total_count = 0
|
|
|
|
for session_dir in agent_sessions.iterdir():
|
|
if session_dir.is_dir() and session_dir.name.startswith('sess_'):
|
|
total_count += 1
|
|
if fix_session_upload(session_dir):
|
|
fixed_count += 1
|
|
|
|
print(f"📊 Résultat : {fixed_count}/{total_count} sessions corrigées")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|