From c80c020e4f27fae0cd0db0e4f3bb18e300b67092 Mon Sep 17 00:00:00 2001 From: Mayeul Aubin Date: Mon, 17 Mar 2025 16:36:09 +0100 Subject: [PATCH] stop progress bar if error is found --- low_level.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/low_level.py b/low_level.py index e987cf0..8d56a98 100644 --- a/low_level.py +++ b/low_level.py @@ -223,6 +223,8 @@ def get_progress_from_logfile(filename): total_operations = int(splitted_line.split("/")[1]) except: pass + elif "Fatal" in line or "Error" in line: + return -1, -1 return current_operation, total_operations @@ -246,6 +248,8 @@ def progress_bar_from_logfile(filename:str, desc:str="", verbose:int=1, **kwargs if current_operation == total_operations: # print_message("Progress bar not needed, the process is already finished.", 3, "low level", verbose=verbose) + if current_operation == -1: + print_message("Error appeared in log file, skipping it.",level=3,module="low level",verbose=verbose) return with tqdm(desc=desc, total=total_operations, disable=(verbose==0), **kwargs) as pbar: @@ -255,6 +259,11 @@ def progress_bar_from_logfile(filename:str, desc:str="", verbose:int=1, **kwargs if current_operation > previous_operation: pbar.update(current_operation-previous_operation) previous_operation = current_operation + if current_operation == -1: + print_message("Error appeared in log file, skipping it.",level=3,module="low level",verbose=verbose) + return k+=1 if k*update_interval >= limit: - print_message(f"Progress bar timed out after {limit} seconds.", 3, "low level", verbose=verbose) \ No newline at end of file + print_message(f"Progress bar timed out after {limit} seconds.", 3, "low level", verbose=verbose) + + return \ No newline at end of file