def cleanup(state): """Cleanup state""" _D.DEBUG(__name__, "App cleanup") # Report execution time duration = datetime.datetime.today() - state.model.date duration = int(duration.total_seconds()) state.set_stats("Execution time, h:m:s", str(datetime.timedelta(seconds=duration))) """ # Alternative method, very cool m, s = divmod(seconds, 60) h, m = divmod(m, 60) print "%d:%02d:%02d" % (h, m, s) """ # Errors and warnings summary count = _D.count_exceptions() if count > 0: state.add_msg_error("Exception(s) count: {}".format(count)) count = _D.count_errors() if count > 0: state.add_msg_error("Error(s) count: {}".format(count)) count = _D.count_warnings() if count > 0: state.add_msg_warning("Warning(s) count: {}".format(count)) # Build backup summary _D.SUMMARY( state.get_description(), state.get_descriptors(), state.get_stats(), state.get_msgs_info(), state.get_msgs_warning(), state.get_msgs_error(), )
def report_needed(state): # If any errors happened then report if _D.count_exceptions() or _D.count_errors() or _D.count_warnings(): return True # If some files were stored then report if state.total_stored_files: return True # NOTE # FOR NOW ALWAYS SAY "YES" # NEED THIS FOR DEBUGGING return True # Otherwise don't report return False