@ -97,6 +97,18 @@ class ExportProgressLogger(_ExportLogger):
self . _time_start_overall = 0
self . _time_start_overall = 0
self . _time_start_step = 0
self . _time_start_step = 0
def __exit__ ( self , type , value , traceback ) :
if value is not None :
export_time = time . perf_counter ( ) - self . _time_start_overall
with self . _print_condition :
self . _progress_print_step ( done = ( self . _step_progress == self . _step_max ) , error = True )
self . _progress_print_line ( " \n ABORTED AFTER {:.2f} s " . format ( export_time ) )
self . _progress_print_heading ( " ERROR " )
self . _progress_print_line ( str ( value ) )
self . _progress_print_heading ( )
self . _progress_alive = False
return super ( ) . __exit__ ( type , value , traceback )
def progress_add_step ( self , name ) :
def progress_add_step ( self , name ) :
assert self . _step_id == - 1
assert self . _step_id == - 1
self . _progress_steps . append ( name )
self . _progress_steps . append ( name )
@ -164,18 +176,18 @@ class ExportProgressLogger(_ExportLogger):
else :
else :
self . _progress_print_line ( " - " * _HEADING_SIZE )
self . _progress_print_line ( " - " * _HEADING_SIZE )
def _progress_print_step ( self , done = False ) :
def _progress_print_step ( self , done = False , error = False ) :
with self . _print_condition :
with self . _print_condition :
if done :
if done :
stage = " DONE IN {:.2f} s " . format ( time . perf_counter ( ) - self . _time_start_step )
stage = " DONE IN {:.2f} s " . format ( time . perf_counter ( ) - self . _time_start_step )
print_func = self . _progress_print_line
print_func = self . _progress_print_line
self . _progress_print_volatile ( " " )
self . _progress_print_volatile ( " " )
else :
else :
if self . _step_max != 0 :
if self . _step_max != 0 and self . _step_progress != 0 :
stage = " {} of {} " . format ( self . _step_progress , self . _step_max )
stage = " {} of {} " . format ( self . _step_progress , self . _step_max )
else :
else :
stage = " "
stage = " "
print_func = self . _progress_print_volatile
print_func = self . _progress_print_line if error else self . _progress_print_ volatile
line = " {} \t (step {} / {} ): {} " . format ( self . _progress_steps [ self . _step_id ] , self . _step_id + 1 ,
line = " {} \t (step {} / {} ): {} " . format ( self . _progress_steps [ self . _step_id ] , self . _step_id + 1 ,
len ( self . _progress_steps ) , stage )
len ( self . _progress_steps ) , stage )