- 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>
198 lines
5.7 KiB
Python
198 lines
5.7 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""
|
|
Test de Diagnostic de Capture d'Écran - RPA Vision V3
|
|
Auteur : Dom, Alice, Kiro - 8 janvier 2026
|
|
|
|
Test simple pour diagnostiquer les problèmes de capture d'écran.
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
|
|
def test_dependencies():
|
|
"""Test des dépendances requises"""
|
|
print("=== Test des Dépendances ===")
|
|
|
|
# Test MSS
|
|
try:
|
|
import mss
|
|
print("✅ MSS disponible")
|
|
|
|
# Test de capture simple
|
|
with mss.mss() as sct:
|
|
monitors = sct.monitors
|
|
print(f"✅ Moniteurs détectés: {len(monitors)}")
|
|
|
|
# Tenter une capture
|
|
if len(monitors) > 0:
|
|
screenshot = sct.grab(monitors[0])
|
|
print(f"✅ Capture réussie: {screenshot.size}")
|
|
|
|
except ImportError:
|
|
print("❌ MSS non disponible")
|
|
except Exception as e:
|
|
print(f"❌ Erreur MSS: {e}")
|
|
|
|
# Test OpenCV
|
|
try:
|
|
import cv2
|
|
print("✅ OpenCV disponible")
|
|
except ImportError:
|
|
print("❌ OpenCV non disponible")
|
|
|
|
# Test PIL
|
|
try:
|
|
from PIL import Image
|
|
print("✅ PIL disponible")
|
|
except ImportError:
|
|
print("❌ PIL non disponible")
|
|
|
|
# Test numpy
|
|
try:
|
|
import numpy as np
|
|
print("✅ NumPy disponible")
|
|
except ImportError:
|
|
print("❌ NumPy non disponible")
|
|
|
|
def test_simple_capture():
|
|
"""Test de capture simple"""
|
|
print("\n=== Test de Capture Simple ===")
|
|
|
|
try:
|
|
import mss
|
|
import numpy as np
|
|
from PIL import Image
|
|
import base64
|
|
import io
|
|
|
|
with mss.mss() as sct:
|
|
# Capturer le premier moniteur
|
|
monitor = sct.monitors[0]
|
|
print(f"Capture du moniteur: {monitor}")
|
|
|
|
screenshot = sct.grab(monitor)
|
|
print(f"Screenshot capturé: {screenshot.size}")
|
|
|
|
# Convertir en array numpy
|
|
img_array = np.array(screenshot)
|
|
print(f"Array shape: {img_array.shape}")
|
|
|
|
# Convertir en PIL Image
|
|
if img_array.shape[2] == 4: # BGRA
|
|
img_array = img_array[:, :, :3] # Supprimer le canal alpha
|
|
|
|
pil_image = Image.fromarray(img_array)
|
|
print(f"PIL Image: {pil_image.size} {pil_image.mode}")
|
|
|
|
# Convertir en base64
|
|
buffer = io.BytesIO()
|
|
pil_image.save(buffer, format='JPEG', quality=85)
|
|
img_base64 = base64.b64encode(buffer.getvalue()).decode('utf-8')
|
|
|
|
print(f"✅ Base64 généré: {len(img_base64)} caractères")
|
|
print(f"Début: {img_base64[:50]}...")
|
|
|
|
return True
|
|
|
|
except Exception as e:
|
|
print(f"❌ Erreur lors de la capture: {e}")
|
|
import traceback
|
|
traceback.print_exc()
|
|
return False
|
|
|
|
def test_service_import():
|
|
"""Test d'import du service"""
|
|
print("\n=== Test d'Import du Service ===")
|
|
|
|
try:
|
|
# Ajouter le chemin du projet
|
|
project_root = os.path.abspath('.')
|
|
if project_root not in sys.path:
|
|
sys.path.insert(0, project_root)
|
|
|
|
from visual_workflow_builder.backend.services.real_screen_capture import RealScreenCaptureService
|
|
print("✅ Service importé avec succès")
|
|
|
|
# Créer une instance
|
|
service = RealScreenCaptureService()
|
|
print("✅ Service instancié")
|
|
|
|
# Tester les moniteurs
|
|
monitors = service.get_monitors()
|
|
print(f"✅ Moniteurs: {len(monitors)}")
|
|
|
|
# Tester le statut
|
|
status = service.get_status()
|
|
print(f"✅ Statut: {status}")
|
|
|
|
return service
|
|
|
|
except Exception as e:
|
|
print(f"❌ Erreur d'import: {e}")
|
|
import traceback
|
|
traceback.print_exc()
|
|
return None
|
|
|
|
def test_manual_capture():
|
|
"""Test de capture manuelle"""
|
|
print("\n=== Test de Capture Manuelle ===")
|
|
|
|
service = test_service_import()
|
|
if not service:
|
|
return False
|
|
|
|
try:
|
|
# Démarrer la capture
|
|
print("Démarrage de la capture...")
|
|
success = service.start_capture(interval=1.0)
|
|
print(f"Capture démarrée: {success}")
|
|
|
|
if success:
|
|
# Attendre un peu
|
|
import time
|
|
print("Attente de 3 secondes...")
|
|
time.sleep(3.0)
|
|
|
|
# Vérifier le statut
|
|
status = service.get_status()
|
|
print(f"Statut: {status}")
|
|
|
|
# Obtenir une capture
|
|
screenshot = service.get_current_screenshot_base64()
|
|
if screenshot:
|
|
print(f"✅ Screenshot obtenu: {len(screenshot)} caractères")
|
|
else:
|
|
print("❌ Aucun screenshot disponible")
|
|
|
|
# Arrêter la capture
|
|
service.stop_capture()
|
|
print("Capture arrêtée")
|
|
|
|
return screenshot is not None
|
|
|
|
except Exception as e:
|
|
print(f"❌ Erreur lors du test: {e}")
|
|
import traceback
|
|
traceback.print_exc()
|
|
return False
|
|
|
|
finally:
|
|
service.cleanup()
|
|
|
|
if __name__ == "__main__":
|
|
print("🔍 Diagnostic du Système de Capture d'Écran")
|
|
print("=" * 50)
|
|
|
|
# Tests séquentiels
|
|
test_dependencies()
|
|
|
|
if test_simple_capture():
|
|
print("\n✅ Capture simple réussie")
|
|
|
|
if test_manual_capture():
|
|
print("\n🎉 Tous les tests réussis !")
|
|
else:
|
|
print("\n❌ Échec du test de service")
|
|
else:
|
|
print("\n❌ Échec de la capture simple") |