stop progress bar if error is found

This commit is contained in:
Mayeul Aubin 2025-03-17 16:36:09 +01:00
parent 942f775425
commit c80c020e4f

View file

@ -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)
print_message(f"Progress bar timed out after {limit} seconds.", 3, "low level", verbose=verbose)
return