Skip to content

Commit

Permalink
refactor method names
Browse files Browse the repository at this point in the history
  • Loading branch information
feng-j678 committed Oct 3, 2023
1 parent 51a3d53 commit 6a92ec0
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/core/src/service_interfaces/StatusHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def set_assessment_substatus_json(self, status=Constants.STATUS_TRANSITIONING, c
self.__assessment_substatus_json = self.__new_substatus_json_for_operation(Constants.PATCH_ASSESSMENT_SUMMARY, status, code, json.dumps(self.__assessment_summary_json))

# Set force truncation true when final status is success or error
self.__set_force_truncation_true(status)
self.__set_force_truncation_true_for_terminal_status(status)

# Update complete status on disk
self.__write_status_file()
Expand Down Expand Up @@ -403,7 +403,7 @@ def set_installation_substatus_json(self, status=Constants.STATUS_TRANSITIONING,
self.__installation_substatus_json = self.__new_substatus_json_for_operation(Constants.PATCH_INSTALLATION_SUMMARY, status, code, json.dumps(self.__installation_summary_json))

# Set force truncation true when final status is success or error
self.__set_force_truncation_true(status)
self.__set_force_truncation_true_for_terminal_status(status)

# Update complete status on disk
self.__write_status_file()
Expand Down Expand Up @@ -479,7 +479,7 @@ def set_patch_metadata_for_healthstore_substatus_json(self, status=Constants.STA
self.__metadata_for_healthstore_substatus_json = self.__new_substatus_json_for_operation(Constants.PATCH_METADATA_FOR_HEALTHSTORE, status, code, json.dumps(self.__metadata_for_healthstore_summary_json))

# Set force truncation true when final status is success or error
self.__set_force_truncation_true(status)
self.__set_force_truncation_true_for_terminal_status(status)

# Update complete status on disk
self.__write_status_file()
Expand Down Expand Up @@ -515,7 +515,7 @@ def set_configure_patching_substatus_json(self, status=Constants.STATUS_TRANSITI
self.__configure_patching_substatus_json = self.__new_substatus_json_for_operation(Constants.CONFIGURE_PATCHING_SUMMARY, status, code, json.dumps(self.__configure_patching_summary_json))

# Set force truncation true when final status is success or error
self.__set_force_truncation_true(status)
self.__set_force_truncation_true_for_terminal_status(status)

# Update complete status on disk
self.__write_status_file()
Expand Down Expand Up @@ -764,7 +764,7 @@ def __write_status_file(self):
self.env_layer.file_system.write_with_retry_using_temp_file(self.complete_status_file_path, '[{0}]'.format(status_file_payload_json_dumps), mode='w+')

if Constants.StatusTruncationConfig.TURN_ON_TRUNCATION:
truncated_status_file_json_dumps = self.__validate_status_file_for_truncation(status_file_payload_json_dumps)
truncated_status_file_json_dumps = self.__check_status_file_size_perform_truncation_if_needed(status_file_payload_json_dumps)

# Write status file <seq.no>.status
if self.__is_file_truncated:
Expand Down Expand Up @@ -910,12 +910,12 @@ def __check_truncation_time_passed_by_x_sec(self, track_truncation_timestamp):
curr_timestamp = datetime.datetime.now()
return (curr_timestamp - track_truncation_timestamp).total_seconds() >= Constants.StatusTruncationConfig.SKIP_TRUNCATION_LOGIC_IN_X_SEC

def __set_force_truncation_true(self, status):
def __set_force_truncation_true_for_terminal_status(self, status):
""" status file needs truncation and last operation is either success or error, then force truncation on last operation"""
if self.__is_file_truncated and (status == Constants.STATUS_SUCCESS or status == Constants.STATUS_ERROR):
self.__force_truncation_on = True

def __validate_status_file_for_truncation(self, status_file_payload_json_dumps):
def __check_status_file_size_perform_truncation_if_needed(self, status_file_payload_json_dumps):
status_file_size_in_bytes = self.__calc_status_size_on_disk(status_file_payload_json_dumps) # calc complete_status_file_payload byte size on disk

if status_file_size_in_bytes > self.__internal_file_capacity: # perform truncation complete_status_file byte size > 126kb
Expand Down

0 comments on commit 6a92ec0

Please sign in to comment.