def write_upload_json(self): """Generate the upload.json.""" assets = self.asset_info["asset"] upload_asset = [] self.upload_info["scene"] = [{ "local": self.cg_file.replace("\\", "/"), "server": utils.convert_path(self.cg_file), "hash": self.get_file_md5(self.cg_file) }] for path in assets: resources = {} local = path.split(" (mtime")[0] server = utils.convert_path(local) resources["local"] = local.replace("\\", "/") resources["server"] = server upload_asset.append(resources) # Add the cg file to upload.json upload_asset.append({ "local": self.cg_file.replace("\\", "/"), "server": utils.convert_path(self.cg_file) }) self.upload_info["asset"] = upload_asset utils.json_save(self.upload_json, self.upload_info)
def handle_analyse_result(self): """handle analyse result. Save the analyzed scene file information and texture information to the upload.json file. """ upload_asset = [] asset_json = self.asset_json normal = asset_json["Normal"] for _, value in normal.items(): path_list = value[-1] for path in path_list: d = {} local = path server = utils.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": utils.convert_path(self.cg_file) }) upload_json = {} upload_json["asset"] = upload_asset self.upload_json = upload_json self.task.upload_info = upload_json utils.json_save(self.task.upload_json_path, upload_json)
def gather_upload_dict(self): """Gather upload info. Examples: { "asset": [ { "local": "E:/copy/muti_layer_test.ma", "server": "/E/copy/muti_layer_test.ma" } ] } """ self.upload_info = utils.json_load(self.upload_json) self.upload_info["asset"].append({ "local": self.cg_file.replace("\\", "/"), "server": convert_path(self.cg_file) }) self.upload_info["scene"] = [{ "local": self.cg_file.replace("\\", "/"), "server": convert_path(self.cg_file), "hash": self.get_file_md5(self.cg_file) }] utils.json_save(self.upload_json, self.upload_info)
def test_json_save(data, encoding, tmpdir): """Test the json_save feature. Test We can get an ``IOError`` if the information is wrong. """ _path = tmpdir.mkdir("test_examples2") json_path = _path.mkdir("small") with pytest.raises(IOError): json_save(str(json_path), data, encoding) json_path_chinese = _path.mkdir("小") with pytest.raises(IOError): json_save(str(json_path_chinese), data, encoding)
def write_task_json(self): """The initialization task.json.""" constants.TASK_INFO["task_info"][ "input_cg_file"] = self.cg_file.replace("\\", "/") constants.TASK_INFO["task_info"]["project_name"] = self.project_name constants.TASK_INFO["task_info"]["cg_id"] = constants.CG_SETTING.get( self.render_software.capitalize()) constants.TASK_INFO["task_info"][ "os_name"] = "1" if self.local_os == "windows" else "0" constants.TASK_INFO["task_info"]["platform"] = self.platform constants.TASK_INFO["software_config"] = { "plugins": self.plugin_config, "cg_version": self.software_version, "cg_name": self.render_software } utils.json_save(self.task_json, constants.TASK_INFO)
def save_tips(self, path=None): """Save the prompt to the tips.json file. Args: path (str, optional): The configuration information path path. """ if path is None: if self.path: path = self.path else: raise RayvisionError(20003, "The TipsInfo' path is not defined.") filename = os.path.join(path, "tips.json") utils.json_save(filename, self.tips_list, ensure_ascii=False)
def write_upload_json(self): """handle analyse result. Save the analyzed scene file information and texture information to the upload.json file. """ upload_asset = [] self.upload_info["scene"] = [{ "local": self.cg_file.replace("\\", "/"), "server": utils.convert_path(self.cg_file), "hash": self.get_file_md5(self.cg_file) }] upload_asset.append({ "local": self.cg_file.replace("\\", "/"), "server": utils.convert_path(self.cg_file) }) self.upload_info["asset"] = upload_asset utils.json_save(self.upload_json, self.upload_info)
def save_tips(self): """Write the error message to tips.json.""" utils.json_save(self.tips_json, self.tips_info, ensure_ascii=False)