Eliminada la ventana emergente de cmd al ejecutar los scripts en windows

This commit is contained in:
Miguel 2025-05-03 17:26:55 +02:00
parent 6ffdec7a9a
commit d63abc971c
7 changed files with 89 additions and 27 deletions

View File

@ -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 ---

View File

@ -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 ---

View File

@ -8,8 +8,6 @@
"output_dir": "D:/Datos/Salida", "output_dir": "D:/Datos/Salida",
"batch_size": 50 "batch_size": 50
}, },
"level3": { "level3": {},
"in_dir": "ingesta"
},
"working_directory": "C:\\Estudio" "working_directory": "C:\\Estudio"
} }

View File

@ -4,6 +4,7 @@ import subprocess
import re import re
import traceback import traceback
from typing import Dict, Any, List, Optional from typing import Dict, Any, List, Optional
import sys # Import sys to check the platform
import time # Add this import import time # Add this import
from datetime import datetime # 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}..." start_msg = f"[{start_time.strftime('%H:%M:%S')}] Iniciando ejecución de {script_name} en {working_dir}..."
broadcast_fn(start_msg) 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 # Execute the script
process = subprocess.Popen( process = subprocess.Popen(
["python", "-u", script_path], # Added -u for unbuffered output ["python", "-u", script_path], # Added -u for unbuffered output
@ -825,6 +831,7 @@ class ConfigurationManager:
errors="replace", errors="replace",
bufsize=1, bufsize=1,
env=dict(os.environ, PYTHONIOENCODING="utf-8"), env=dict(os.environ, PYTHONIOENCODING="utf-8"),
creationflags=creation_flags, # Add this line
) )
# Real-time stdout reading and broadcasting # Real-time stdout reading and broadcasting

View File

@ -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:26:22] Iniciando ejecución de x1.py en C:\Estudio...
[17:15:14] Working directory: C:\Trabajo\SIDEL\EMAILs\I_ E5.007727 _ Evo On - SFSRFH300172 + SFSRFH300109 - ANDIA LACTEOS [17:26:22] === Ejecutando Script de Prueba 1 ===
[17:15:14] Input directory: C:\Trabajo\SIDEL\EMAILs\I_ E5.007727 _ Evo On - SFSRFH300172 + SFSRFH300109 - ANDIA LACTEOS [17:26:22] Configuraciones cargadas:
[17:15:14] Output directory: C:/Users/migue/OneDrive/Miguel/Obsidean/Trabajo/VM/04-SIDEL/00 - MASTER/EMAILs [17:26:22] Nivel 1: {
[17:15:14] Cronologia file: C:/Users/migue/OneDrive/Miguel/Obsidean/Trabajo/VM/04-SIDEL/00 - MASTER/EMAILs\cronologia.md [17:26:22] "api_key": "your-api-key-here",
[17:15:14] Attachments directory: C:\Trabajo\SIDEL\EMAILs\I_ E5.007727 _ Evo On - SFSRFH300172 + SFSRFH300109 - ANDIA LACTEOS\adjuntos [17:26:22] "model": "gpt-3.5-turbo"
[17:15:14] Beautify rules file: D:\Proyectos\Scripts\ParamManagerScripts\backend\script_groups\EmailCrono\config\beautify_rules.json [17:26:22] }
[17:15:14] Found 1 .eml files [17:26:22] Nivel 2: {
[17:15:14] Loaded 0 existing messages [17:26:22] "input_dir": "D:/Datos/Entrada",
[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:26:22] "output_dir": "D:/Datos/Salida",
[17:15:14] Aplicando reglas de prioridad 1 [17:26:22] "batch_size": 50
[17:15:14] Aplicando reglas de prioridad 2 [17:26:22] }
[17:15:14] Aplicando reglas de prioridad 3 [17:26:22] Nivel 3: {}
[17:15:14] Aplicando reglas de prioridad 4 [17:26:22] Simulando procesamiento...
[17:15:14] Estadísticas de procesamiento: [17:26:23] Progreso: 20%
[17:15:14] - Total mensajes encontrados: 1 [17:26:24] Progreso: 40%
[17:15:14] - Mensajes únicos añadidos: 1 [17:26:25] Progreso: 60%
[17:15:14] - Mensajes duplicados ignorados: 0 [17:26:26] Progreso: 80%
[17:15:14] Writing 1 messages to C:/Users/migue/OneDrive/Miguel/Obsidean/Trabajo/VM/04-SIDEL/00 - MASTER/EMAILs\cronologia.md [17:26:27] Progreso: 100%
[17:15:14] Ejecución de x1.py finalizada (success). Duración: 0:00:01.628641. [17:26:27] ¡Proceso completado!
[17:15:14] Log completo guardado en: D:\Proyectos\Scripts\ParamManagerScripts\backend\script_groups\EmailCrono\log_x1.txt [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

View File

@ -1030,8 +1030,8 @@ function fetchLogs() {
fetch('/api/logs') fetch('/api/logs')
.then(response => response.json()) .then(response => response.json())
.then(data => { .then(data => {
const logOutput = document.getElementById('log-output'); const logOutput = document.getElementById('log-area'); // Corregido ID a log-area
logOutput.textContent = data.logs || 'No hay logs.'; logOutput.innerHTML = data.logs || 'No hay logs.'; // Usar innerHTML para mantener formato si existe
logOutput.scrollTop = logOutput.scrollHeight; // Scroll to bottom logOutput.scrollTop = logOutput.scrollHeight; // Scroll to bottom
}) })
.catch(error => console.error('Error fetching logs:', error)); .catch(error => console.error('Error fetching logs:', error));
@ -1043,7 +1043,8 @@ function clearLogs() {
.then(response => response.json()) .then(response => response.json())
.then(data => { .then(data => {
if (data.status === 'success') { 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.'); showToast('Logs borrados correctamente.');
} else { } else {
showToast('Error al borrar los logs.', 'error'); showToast('Error al borrar los logs.', 'error');