diff --git a/__pycache__/config_manager.cpython-312.pyc b/__pycache__/config_manager.cpython-312.pyc index 99d4791..4a46e5d 100644 Binary files a/__pycache__/config_manager.cpython-312.pyc and b/__pycache__/config_manager.cpython-312.pyc differ diff --git a/backend/script_groups/example_group/log_x1.txt b/backend/script_groups/example_group/log_x1.txt new file mode 100644 index 0000000..cad1585 --- /dev/null +++ b/backend/script_groups/example_group/log_x1.txt @@ -0,0 +1,35 @@ +--- Log de Ejecución: x1.py --- +Grupo: example_group +Directorio de Trabajo: C:\Estudio +Inicio: 2025-05-03 17:26:22 +Fin: 2025-05-03 17:26:27 +Duración: 0:00:05.167151 +Estado: SUCCESS (Código de Salida: 0) + +--- SALIDA ESTÁNDAR (STDOUT) --- +=== Ejecutando Script de Prueba 1 === + +Configuraciones cargadas: +Nivel 1: { + "api_key": "your-api-key-here", + "model": "gpt-3.5-turbo" +} +Nivel 2: { + "input_dir": "D:/Datos/Entrada", + "output_dir": "D:/Datos/Salida", + "batch_size": 50 +} +Nivel 3: {} + +Simulando procesamiento... +Progreso: 20% +Progreso: 40% +Progreso: 60% +Progreso: 80% +Progreso: 100% + +¡Proceso completado! + +--- ERRORES (STDERR) --- +Ninguno +--- FIN DEL LOG --- diff --git a/backend/script_groups/example_group/log_x2.txt b/backend/script_groups/example_group/log_x2.txt new file mode 100644 index 0000000..8bbea37 --- /dev/null +++ b/backend/script_groups/example_group/log_x2.txt @@ -0,0 +1,20 @@ +--- Log de Ejecución: x2.py --- +Grupo: example_group +Directorio de Trabajo: C:\Estudio +Inicio: 2025-05-03 17:26:13 +Fin: 2025-05-03 17:26:14 +Duración: 0:00:01.149705 +Estado: SUCCESS (Código de Salida: 0) + +--- SALIDA ESTÁNDAR (STDOUT) --- +=== Ejecutando Script de Prueba 2 === + +Iniciando análisis de datos simulado... +Analizando lote 1... + +ERROR: Error simulado en el procesamiento +El proceso se detuvo debido a un error + +--- ERRORES (STDERR) --- +Ninguno +--- FIN DEL LOG --- diff --git a/backend/script_groups/example_group/script_config.json b/backend/script_groups/example_group/script_config.json index 8f70403..2b3959c 100644 --- a/backend/script_groups/example_group/script_config.json +++ b/backend/script_groups/example_group/script_config.json @@ -8,8 +8,6 @@ "output_dir": "D:/Datos/Salida", "batch_size": 50 }, - "level3": { - "in_dir": "ingesta" - }, + "level3": {}, "working_directory": "C:\\Estudio" } \ No newline at end of file diff --git a/config_manager.py b/config_manager.py index e510401..7e868e1 100644 --- a/config_manager.py +++ b/config_manager.py @@ -4,6 +4,7 @@ import subprocess import re import traceback from typing import Dict, Any, List, Optional +import sys # Import sys to check the platform import time # Add this import from datetime import datetime # Add this import @@ -814,6 +815,11 @@ class ConfigurationManager: start_msg = f"[{start_time.strftime('%H:%M:%S')}] Iniciando ejecución de {script_name} en {working_dir}..." broadcast_fn(start_msg) + # Determine creation flags for subprocess based on OS + creation_flags = 0 + if sys.platform == "win32": + creation_flags = subprocess.CREATE_NO_WINDOW + # Execute the script process = subprocess.Popen( ["python", "-u", script_path], # Added -u for unbuffered output @@ -825,6 +831,7 @@ class ConfigurationManager: errors="replace", bufsize=1, env=dict(os.environ, PYTHONIOENCODING="utf-8"), + creationflags=creation_flags, # Add this line ) # Real-time stdout reading and broadcasting diff --git a/data/log.txt b/data/log.txt index dc990f9..15570d3 100644 --- a/data/log.txt +++ b/data/log.txt @@ -1,21 +1,22 @@ -[17:15:12] Iniciando ejecución de x1.py en C:\Trabajo\SIDEL\EMAILs\I_ E5.007727 _ Evo On - SFSRFH300172 + SFSRFH300109 - ANDIA LACTEOS... -[17:15:14] Working directory: C:\Trabajo\SIDEL\EMAILs\I_ E5.007727 _ Evo On - SFSRFH300172 + SFSRFH300109 - ANDIA LACTEOS -[17:15:14] Input directory: C:\Trabajo\SIDEL\EMAILs\I_ E5.007727 _ Evo On - SFSRFH300172 + SFSRFH300109 - ANDIA LACTEOS -[17:15:14] Output directory: C:/Users/migue/OneDrive/Miguel/Obsidean/Trabajo/VM/04-SIDEL/00 - MASTER/EMAILs -[17:15:14] Cronologia file: C:/Users/migue/OneDrive/Miguel/Obsidean/Trabajo/VM/04-SIDEL/00 - MASTER/EMAILs\cronologia.md -[17:15:14] Attachments directory: C:\Trabajo\SIDEL\EMAILs\I_ E5.007727 _ Evo On - SFSRFH300172 + SFSRFH300109 - ANDIA LACTEOS\adjuntos -[17:15:14] Beautify rules file: D:\Proyectos\Scripts\ParamManagerScripts\backend\script_groups\EmailCrono\config\beautify_rules.json -[17:15:14] Found 1 .eml files -[17:15:14] Loaded 0 existing messages -[17:15:14] Processing C:\Trabajo\SIDEL\EMAILs\I_ E5.007727 _ Evo On - SFSRFH300172 + SFSRFH300109 - ANDIA LACTEOS\I_ E5.007727 _ Evo On - SFSRFH300172 + SFSRFH300109 - ANDIA LACTEOS.eml -[17:15:14] Aplicando reglas de prioridad 1 -[17:15:14] Aplicando reglas de prioridad 2 -[17:15:14] Aplicando reglas de prioridad 3 -[17:15:14] Aplicando reglas de prioridad 4 -[17:15:14] Estadísticas de procesamiento: -[17:15:14] - Total mensajes encontrados: 1 -[17:15:14] - Mensajes únicos añadidos: 1 -[17:15:14] - Mensajes duplicados ignorados: 0 -[17:15:14] Writing 1 messages to C:/Users/migue/OneDrive/Miguel/Obsidean/Trabajo/VM/04-SIDEL/00 - MASTER/EMAILs\cronologia.md -[17:15:14] Ejecución de x1.py finalizada (success). Duración: 0:00:01.628641. -[17:15:14] Log completo guardado en: D:\Proyectos\Scripts\ParamManagerScripts\backend\script_groups\EmailCrono\log_x1.txt +[17:26:22] Iniciando ejecución de x1.py en C:\Estudio... +[17:26:22] === Ejecutando Script de Prueba 1 === +[17:26:22] Configuraciones cargadas: +[17:26:22] Nivel 1: { +[17:26:22] "api_key": "your-api-key-here", +[17:26:22] "model": "gpt-3.5-turbo" +[17:26:22] } +[17:26:22] Nivel 2: { +[17:26:22] "input_dir": "D:/Datos/Entrada", +[17:26:22] "output_dir": "D:/Datos/Salida", +[17:26:22] "batch_size": 50 +[17:26:22] } +[17:26:22] Nivel 3: {} +[17:26:22] Simulando procesamiento... +[17:26:23] Progreso: 20% +[17:26:24] Progreso: 40% +[17:26:25] Progreso: 60% +[17:26:26] Progreso: 80% +[17:26:27] Progreso: 100% +[17:26:27] ¡Proceso completado! +[17:26:27] Ejecución de x1.py finalizada (success). Duración: 0:00:05.167151. +[17:26:27] Log completo guardado en: D:\Proyectos\Scripts\ParamManagerScripts\backend\script_groups\example_group\log_x1.txt diff --git a/static/js/scripts.js b/static/js/scripts.js index aaa89a6..7936e53 100644 --- a/static/js/scripts.js +++ b/static/js/scripts.js @@ -1030,8 +1030,8 @@ function fetchLogs() { fetch('/api/logs') .then(response => response.json()) .then(data => { - const logOutput = document.getElementById('log-output'); - logOutput.textContent = data.logs || 'No hay logs.'; + const logOutput = document.getElementById('log-area'); // Corregido ID a log-area + logOutput.innerHTML = data.logs || 'No hay logs.'; // Usar innerHTML para mantener formato si existe logOutput.scrollTop = logOutput.scrollHeight; // Scroll to bottom }) .catch(error => console.error('Error fetching logs:', error)); @@ -1043,7 +1043,8 @@ function clearLogs() { .then(response => response.json()) .then(data => { if (data.status === 'success') { - fetchLogs(); // Refresh logs after clearing + // Limpiar el área de log visualmente AHORA + document.getElementById('log-area').innerHTML = ''; showToast('Logs borrados correctamente.'); } else { showToast('Error al borrar los logs.', 'error');