def handle_analyse_result(self): upload_asset = [] asset_json = self.asset_json assets = asset_json["asset"] for asset_dict in assets: path_list = asset_dict["path"] for path in path_list: d = {} local = path server = util.convert_path("", local) d["local"] = local.replace("\\", "/") d["server"] = server upload_asset.append(d) # Add the cg file to upload.json upload_asset.append({ "local": self.cg_file.replace("\\", "/"), "server": util.convert_path("", self.cg_file) }) upload_json = {} upload_json["asset"] = upload_asset self.upload_json = upload_json self.job_info._upload_info = upload_json util.json_save(self.job_info._upload_json_path, upload_json)
def handle_analyse_result(self): upload_asset = [] asset_json = self.asset_json normal = asset_json["Normal"] ## eg. asset = {"Normal":{"node1":["nodename",["files"]],"node2":["nodename",["files"]]}, ## "Miss":{"node1":["nodename",["files"]],"node2":["nodename",["files"]]}} for _, value in normal.items(): path_list = value[-1] for path in path_list: d = {} local = path server = util.convert_path("", local) d["local"] = local.replace("\\", "/") d["server"] = server upload_asset.append(d) # handle upload.json upload_asset.append({ "local": self.cg_file.replace("\\", "/"), "server": util.convert_path("", self.cg_file) }) upload_json = {} upload_json["asset"] = upload_asset self.upload_json = upload_json self.job_info._upload_info = upload_json util.json_save(self.job_info._upload_json_path, upload_json)
def save(self, path=None): if path is None: if self.path is not None: path = self.path else: raise Exception("The Tips' path is not defined") filename = os.path.join(path, "tips.json") util.json_save(filename, self._tips_list, ensure_ascii=False)
def write_vray(self): if "vray" in self.vray: task_path = self.job_info._task_json_path task_json = self.job_info._task_info task_json["software_config"]["plugins"][ "vray"] = self.vray.replace("vray", "") util.json_save(task_path, task_json, ensure_ascii=False) self.task_json = task_json self.job_info._task_info = task_json
def write_cg_path(self): """Write cg_file and cg_id into task_info""" cg_id = self.cg_id cg_file = self.cg_file task_info = self.job_info._task_info["task_info"] task_info["input_cg_file"] = cg_file.replace("\\", "/") task_info["cg_id"] = cg_id util.json_save(self.job_info._task_json_path, self.job_info._task_info, ensure_ascii=False)
def handle_analyse_result(self): # Remove zip list compression asset_json = self.asset_json key = "zip" if key in asset_json: maxs = asset_json[key] assert type(maxs) == list # Compress .max file, get the compressed path list zip_result_dict = self.zip_max(maxs) else: zip_result_dict = {} asset_json.pop(key) # Assemble the full path including max.zip and the path that should be uploaded in asset.json to upload.json upload_json = self.assemble_upload_json(asset_json, zip_result_dict) self.upload_json = upload_json self.job_info._upload_info = upload_json util.json_save(self.job_info._upload_json_path, upload_json, ensure_ascii=False)
def load_output_json(self): task_path = self.job_info._task_json_path temp_task_path = os.path.join(os.path.dirname(task_path), self.temp_task_json_name) asset_path = self.job_info._asset_json_path tips_path = self.job_info._tips_json_path encodings = ["utf-8-sig", "gbk", "utf-8"] temp_task_json = self.json_load(temp_task_path, encodings=encodings) asset_json = self.json_load(asset_path, encodings=encodings) tips_json = self.json_load(tips_path, encodings=encodings) # Add the contents of temp_task.json to task.json and write it as a file task_json = self.job_info._task_info # Directory update the replacement task_json.update(temp_task_json) util.json_save(task_path, task_json, ensure_ascii=False) # json contains BOM, need to be converted to non-contain BOM util.json_save(asset_path, asset_json, ensure_ascii=False) util.json_save(tips_path, tips_json, ensure_ascii=False) self.task_json = task_json self.job_info._task_info = task_json self.asset_json = asset_json self.job_info._asset_info = asset_json self.tips_json = tips_json self.job_info._tips_info = tips_json
def dump_task_json(self): self.log.debug("run CG.dump_task_json") task_json = self.job_info._task_info util.json_save(self.job_info._task_json_path, task_json, ensure_ascii=False)