def __init__(self, file_name, file_path, file_type, file_size, modification_time, root_key, environment_name): self.folder_path = COMPARE_FILE_PATH + root_key + "/" + environment_name create_folder(self.folder_path) self.local_path = self.folder_path + "/" + file_name self.environment_name = environment_name super().__init__(file_name, file_path, file_type, file_size, modification_time, self.local_path)
def download_git_files(self, root_key, connect_obj): file_object = SharedStorageFileLoadObject(self.name, self.path, self.type, self.size, self.modification_time, root_key, self.environment.name) create_folder(file_object.folder_path) resource_path = connect_obj.root_path + file_object.file_path copied_path = file_object.local_path copyfile(resource_path, copied_path) return file_object
def download_exist_files(self, resource_root_key, new_root_key): file_object = SharedStorageFileLoadObject(self.name, self.path, self.type, self.size, self.modification_time, new_root_key, self.environment.name) create_folder(file_object.folder_path) resource_path = get_download_file_path(resource_root_key, self.environment.name, self.name) copied_path = file_object.local_path copyfile(resource_path, copied_path) return file_object
def save_file(self, response_xml, ruleset_name): ruleset_xml = response_xml.payload[response_xml.payload. index('<BRERuleList'):] # replace xml tag ruleset_list = RulesetObject(ruleset_xml, ruleset_name).get_rules_model_array() new_ruleset_xml = build_ruleset_xml(ruleset_list) # save file fileManager.create_folder(self.file_name_with_path) fileManager.save_file( get_rule_set_full_file_name(self.file_name_with_path, ruleset_name), new_ruleset_xml)
def generate_report_mail_attachment(task): copy_path = RULESET_COMPARE_RESULT_FOLDER_PATH % str(task.compare_hash_key) fileManager.create_folder(copy_path) resource_full_path = RULESET_COMPARE_RESULT_HTML % task.compare_hash_key copy_full_path = RULESET_COMPARE_RESULT_ZIP_RESOURCE % ( task.compare_hash_key, task.compare_hash_key) copyfile(resource_full_path, copy_full_path) # archive single folder report zip_file_path = RULESET_ZIP_FILE_PATH % task.compare_hash_key fileManager.archive_file_with_arcname(copy_path, RULESET_ZIP_PATH, zip_file_path) fileManager.clear_folder(copy_path) return zip_file_path
def save_file_detail_json(root_key, env_name, node_key, json_data): root_path = COMPARE_RESULT_PATH + root_key + "/" + env_name create_folder(root_path) file_path = root_path + "/%s.%s" % (node_key, KEY_JSON) save_file(file_path, json.dumps(json_data))
def save_file_diff_json(root_key, node_key, json_data): root_path = COMPARE_RESULT_PATH + root_key create_folder(root_path) file_path = root_path + "/%s.%s" % (node_key, KEY_JSON) save_file(file_path, json.dumps(json_data))
def copy_rulesets(ruleset_name_list, source_folder_path, target_folder_path): create_folder(target_folder_path) for ruleset_name in ruleset_name_list: source_file_path = source_folder_path + "/" + ruleset_name target_file_path = target_folder_path + "/" + ruleset_name copyfile(source_file_path, target_file_path)
def copy_ruleset(ruleset_name, source_folder_path, target_folder_path): create_folder(target_folder_path) source_file_path = source_folder_path + "/" + ruleset_name target_file_path = target_folder_path + "/" + ruleset_name copyfile(source_file_path, target_file_path)
def save_compare_result_json(json_data, root_hash_key, path_key): file_path = path_key + "%s.%s" % (root_hash_key, KEY_JSON) create_folder(path_key) save_file(file_path, json.dumps(json_data))