ini e email
This commit is contained in:
@@ -11,6 +11,7 @@ from utils.database.action_query import get_tool_info
|
||||
from utils.csv.loaders import get_next_csv_atomic
|
||||
from utils.orchestrator_utils import run_orchestrator, worker_context
|
||||
from utils.database.loader_action import update_status, unlock
|
||||
from utils.connect.send_email import send_error_email
|
||||
|
||||
# Initialize the logger for this module
|
||||
logger = logging.getLogger()
|
||||
@@ -44,7 +45,7 @@ async def worker(worker_id: int, cfg: object, pool: object) -> None:
|
||||
record = await get_next_csv_atomic(pool, cfg.dbrectable, WorkflowFlags.DATA_LOADED, WorkflowFlags.DATA_ELABORATED)
|
||||
if record:
|
||||
id, unit_type, tool_type, unit_name, tool_name = [x.lower().replace(" ", "_") if isinstance(x, str) else x for x in record]
|
||||
if tool_type.lower() != "gd": # i tool GD non devono essere elaborati
|
||||
if tool_type.lower() != "gd": # i tool GD non devono essere elaborati ???
|
||||
tool_elab_info = await get_tool_info(WorkflowFlags.DATA_ELABORATED, unit_name.upper(), tool_name.upper(), pool)
|
||||
if tool_elab_info:
|
||||
if tool_elab_info['statustools'].lower() in cfg.elab_status:
|
||||
@@ -65,6 +66,20 @@ async def worker(worker_id: int, cfg: object, pool: object) -> None:
|
||||
logger.error(stderr.decode().strip())
|
||||
with open(f"{cfg.matlab_error_path}{unit_name}{tool_name}_output_error.txt", "w") as f:
|
||||
f.write(stderr.decode().strip())
|
||||
|
||||
if proc.returncode == 124:
|
||||
error_type = f"Matlab elab excessive duration: killed after {cfg.matlab_timeout} seconds."
|
||||
else:
|
||||
error_type = f"Matlab elab failed: {proc.returncode}."
|
||||
"""
|
||||
da verificare i log degli errori come sono creati... dal perl:
|
||||
"cd $MatlabErrorPath; cat _${unit}_${tool}*_\*_output_error.txt > ${unit}${tool}_output_error.txt";
|
||||
"""
|
||||
errors = [line for line in stderr.decode().strip() if line.startswith("Error")]
|
||||
warnings = [line for line in stderr.decode().strip() if line.startswith("Warning")]
|
||||
await send_error_email(unit_name.upper(), tool_name.upper(), tool_elab_info['matcall'], error_type, errors, warnings) # da verificare
|
||||
|
||||
|
||||
else:
|
||||
logger.info(stdout.decode().strip())
|
||||
await update_status(cfg, id, WorkflowFlags.DATA_ELABORATED, pool)
|
||||
|
||||
Reference in New Issue
Block a user