Index: cloudsync/common/enums.py =================================================================== diff -u -r6c122c0fa1daac67f03da7b8826305d463bfefd9 -rcc36b7572e8d4e67ea514e038f9e07665d6e336f --- cloudsync/common/enums.py (.../enums.py) (revision 6c122c0fa1daac67f03da7b8826305d463bfefd9) +++ cloudsync/common/enums.py (.../enums.py) (revision cc36b7572e8d4e67ea514e038f9e07665d6e336f) @@ -75,7 +75,7 @@ UI2CS_SEND_TREATMENT_REPORT = 1007 UI2CS_REQ_DECOMMISSION = 1009 UI2CS_UPLOAD_DEVICE_LOG = 1010 # DEVICE_LOG - UI2CS_REQ_LOG_ROTATION = 1011 + UI2CS_REQ_LOG_RETENTION = 1011 # INCOMING ERROR UI2CS_ERROR = 1999 @@ -94,7 +94,7 @@ CS2UI_REQ_TX_CODE_DISPLAY = 2008 CS2UI_REQ_DEVICE_DECOMMISSIONED = 2009 CS2UI_DEVICE_LOG_UPLOADED = 2010 - CS2UI_REQ_LOG_ROTATION = 2011 + CS2UI_REQ_LOG_RETENTION = 2011 # OUTGOING ERROR CS2UI_ERROR = 2999 @@ -134,4 +134,4 @@ CS_DEVICE_LOG_ERROR = 930 CS_LOG_ERROR = 931 CS_FACTORY_RESET_ERROR = 932 - CS_LOG_ROTATION_ERROR = 933 + CS_LOG_RETENTION_ERROR = 933 Index: cloudsync/handlers/error_handler.py =================================================================== diff -u -r4ebf654ab1b0d436ce7d171bfe06c6bdc46aca47 -rcc36b7572e8d4e67ea514e038f9e07665d6e336f --- cloudsync/handlers/error_handler.py (.../error_handler.py) (revision 4ebf654ab1b0d436ce7d171bfe06c6bdc46aca47) +++ cloudsync/handlers/error_handler.py (.../error_handler.py) (revision cc36b7572e8d4e67ea514e038f9e07665d6e336f) @@ -52,7 +52,8 @@ return # TODO Add specific UI error message handling when necessary if OutboundMessageIDs.mapped_str_value(error.ID) == OutboundMessageIDs.CS2UI_ERROR: - self.logger.error('CS App Error {0} - {1}: {2}'.format(error.code, ErrorIDs.mapped_str_value(error.code), + self.logger.error('CS App Error {0} - {1}: {2}'.format(error.code, + ErrorIDs.mapped_str_value(error.code), error.parameters)) parameter_string = "" for parameter in error.parameters: Index: cloudsync/handlers/ui_cs_request_handler.py =================================================================== diff -u -rc88f546ad09c2d6c0222d8e694a9814e37a424ea -rcc36b7572e8d4e67ea514e038f9e07665d6e336f --- cloudsync/handlers/ui_cs_request_handler.py (.../ui_cs_request_handler.py) (revision c88f546ad09c2d6c0222d8e694a9814e37a424ea) +++ cloudsync/handlers/ui_cs_request_handler.py (.../ui_cs_request_handler.py) (revision cc36b7572e8d4e67ea514e038f9e07665d6e336f) @@ -232,26 +232,27 @@ e)) self.error_handler.enqueue_error(error=error) - # CS LOG ROTATION - elif InboundMessageIDs.mapped_str_value(message.ID) == InboundMessageIDs.UI2CS_REQ_LOG_ROTATION: - self.logger.info("UI2CS_REQ_LOG_ROTATION request received") - if len(message.parameters) == 1 and int(message.parameters[0]) > 0: + # CS LOG RETENTION + elif InboundMessageIDs.mapped_str_value(message.ID) == InboundMessageIDs.UI2CS_REQ_LOG_RETENTION: + self.logger.info("UI2CS_REQ_LOG_RETENTION request received") + if len(message.parameters) >= 1 and int(message.parameters[0]) > 0: try: - self.logger.debug("Used Percentage: {0}".format(message.parameters[0])) - num_of_files, del_size_mb = helpers_log_rotation(int(message.parameters[0])) + self.logger.info("Used Percentage: {0}".format(message.parameters[0])) + num_of_files, del_size_mb = helpers_log_retention(message.parameters[0]) message_body = str( - OutboundMessageIDs.CS2UI_REQ_LOG_ROTATION.value) + f',{num_of_files}' + f',{del_size_mb}' + OutboundMessageIDs.CS2UI_REQ_LOG_RETENTION.value) + f',{num_of_files}' + f',{del_size_mb}' self.output_channel.enqueue_message(message_body) except Exception as e: error = Error("{0},2,{1},{2}".format(OutboundMessageIDs.CS2UI_ERROR.value, - ErrorIDs.CS_LOG_ROTATION_ERROR.value, + ErrorIDs.CS_LOG_RETENTION_ERROR.value, e)) self.error_handler.enqueue_error(error=error) else: - error = Error("{0},2,{1},invalid # of parameters for log rotation".format( + error = Error("{0},2,{1},invalid # of parameters for log retention".format( OutboundMessageIDs.CS2UI_ERROR.value, - ErrorIDs.CS_LOG_ROTATION_ERROR.value)) + ErrorIDs.CS_LOG_RETENTION_ERROR.value)) self.error_handler.enqueue_error(error=error) + # ERROR MESSAGE RECEIVED FROM UI elif InboundMessageIDs.mapped_str_value(message.ID) == InboundMessageIDs.UI2CS_ERROR: error_body = "{0},{1},{2}".format(InboundMessageIDs.UI2CS_ERROR.value, message.size, Index: cloudsync/utils/helpers.py =================================================================== diff -u -rc88f546ad09c2d6c0222d8e694a9814e37a424ea -rcc36b7572e8d4e67ea514e038f9e07665d6e336f --- cloudsync/utils/helpers.py (.../helpers.py) (revision c88f546ad09c2d6c0222d8e694a9814e37a424ea) +++ cloudsync/utils/helpers.py (.../helpers.py) (revision cc36b7572e8d4e67ea514e038f9e07665d6e336f) @@ -745,8 +745,8 @@ return None -def helpers_log_rotation(rotation_pct): - cs_log_pct = rotation_pct / 100 +def helpers_log_retention(retention_pct): + cs_log_pct = retention_pct / 100 num_files_deleted = 0 total_deleted_size = 0 # Total sd stats