def check_suspended_syncers(syncers_delays, syncer_to_check=None): suspended = False try: for syncer_name, suspension_expiry in syncers_delays.copy().items(): if time.time() < suspension_expiry: # this syncer is still delayed due to a previous abort due to triggers use_logger = log.debug if not ( syncer_to_check and syncer_name == syncer_to_check) else log.info use_logger( "%s is still suspended due to a previously aborted sync. Normal operation in %s at %s", syncer_name, misc.seconds_to_string(int(suspension_expiry - time.time())), time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(suspension_expiry))) # return True when suspended if syncer_to_check is supplied and this is that remote if syncer_to_check and syncer_name == syncer_to_check: suspended = True else: log.warning( "%s is no longer suspended due to a previous aborted sync!", syncer_name) syncers_delays.pop(syncer_name, None) # send notification that remote is no longer timed out notify.send( message="Sync suspension has expired for syncer: %s" % syncer_name) except Exception: log.exception("Exception checking suspended syncers: ") return suspended
def check_suspended_uploaders(uploader_to_check=None): global uploader_delay suspended = False try: for uploader_name, suspension_expiry in dict( uploader_delay.items()).items(): if time.time() < suspension_expiry: # this remote is still delayed due to a previous abort due to triggers use_logger = log.debug if not ( uploader_to_check and uploader_name == uploader_to_check) else log.info use_logger( "%s is still suspended due to a previously aborted upload. Normal operation in %s at %s", uploader_name, misc.seconds_to_string(int(suspension_expiry - time.time())), time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(suspension_expiry))) # return True when suspended if uploader_to_check is supplied and this is that remote if uploader_to_check and uploader_name == uploader_to_check: suspended = True else: log.warning( "%s is no longer suspended due to a previous aborted upload!", uploader_name) uploader_delay.pop(uploader_name, None) # send notification that remote is no longer timed out notify.send( message="Upload suspension has expired for remote: %s" % uploader_name) except Exception: log.exception("Exception checking suspended uploaders: ") return suspended