def perform_cleanup(self): """ Cleanup and old uncollected data files to recover disk space. """ log.msg('Performing cleanup of the output directory...') base_directory = self.server.base_output_directory current_time = datetime.now() for entry in os.listdir(base_directory): entry_path = os.path.join(base_directory, entry) entry_ctime = datetime.fromtimestamp(os.path.getctime(entry_path)) existence_time = current_time - entry_ctime if existence_time > self.cleanup_threshold: log.debug('Removing {} (existed for {})'.format(entry, existence_time)) shutil.rmtree(entry_path) else: log.debug('Keeping {} (existed for {})'.format(entry, existence_time)) log.msg('Cleanup complete.')
def perform_cleanup(self): """ Cleanup and old uncollected data files to recover disk space. """ log.msg('Performing cleanup of the output directory...') base_directory = self.server.base_output_directory current_time = datetime.now() for entry in os.listdir(base_directory): entry_path = os.path.join(base_directory, entry) entry_ctime = datetime.fromtimestamp(os.path.getctime(entry_path)) existence_time = current_time - entry_ctime if existence_time > self.cleanup_threshold: log.debug('Removing {} (existed for {})'.format( entry, existence_time)) shutil.rmtree(entry_path) else: log.debug('Keeping {} (existed for {})'.format( entry, existence_time)) log.msg('Cleanup complete.')
def clientConnectionLost(self, connector, reason): log.msg('client connection lost: {}.'.format(reason)) if not isinstance(reason, ConnectionLost): log.msg('ERROR: Client terminated connection mid-transfer.') for session in self.transfer_sessions: self.transferComplete(session)