def main(file_name, local): logger = logging.getLogger("Anim publish") if not local: open_file.open_file(file_name) # get paths context = pipeFile.PathDetails.parse_path(file_name) publish_path = context.publish_path # reference opt publish.reference_opt() # copy image and video publish.copy_image_and_video(context) logger.info("Copy image and video done.") # save to publish path copy.copy(file_name, publish_path) logger.info("Copy to %s" % publish_path) # export asset info asset_info_path = context.asset_info_path export_anim_asset_info.export_anim_asset_info(asset_info_path) logger.info("Export asset info done.") # write out assembly edits rebuild_assembly.export_scene() logger.info("Export assembly edits done.") # export cache publish.export_cache(context) logger.info("Export cache done.") # quit maya if not local: quit_maya.quit_maya()
def create_delta(self, palette, delta_path): delta_dir = os.path.dirname(delta_path) if not os.path.isdir(delta_dir): os.makedirs(delta_dir) xgen.createDelta(palette, "D:/temp.xgd") copy.copy("D:/temp.xgd", delta_path) os.remove("D:/temp.xgd")
def main(): logger = logging.getLogger(__name__) scene_name = get_scene_name.get_scene_name() # copy scene to temp dir base_name = os.path.basename(scene_name) temp_dir = tempfile.gettempdir() temp_file = join_path.join_path2(temp_dir, base_name) copy.copy(scene_name, temp_file) logger.info("Copy to temp: %s" % temp_file) # copy all textures to _tex try: export_shd_textures.export_shd_textures() except: raise Exception("something wrong with export shd textures.") # save current file save_file.save_file() # copy to QCPublish path context = pipeFile.PathDetails.parse_path() work_path = context.work_path if Copy.copy(scene_name, work_path): logger.info("copy %s >> %s" % (scene_name, work_path)) else: raise RuntimeError("copy to work path error.") # copy from temp file copy.copy(temp_file, scene_name) logger.info("copy from temp.") # delete temp file os.remove(temp_file) # open scene name open_file.open_file(scene_name) logger.info("Reopen %s" % scene_name)
def submit(self): # has screen thumbnail_path = self.submit_screen_shot() if not thumbnail_path: return # preflight preflight_status = self.submit_preflight() if preflight_status is not None: if not preflight_status: return # playblast version_file = self.submit_version() # copy image copy.copy(thumbnail_path, self.local_image_path) copy.copy(thumbnail_path, self.work_image_path) os.remove(thumbnail_path) # step qc self.submit_step_qc() # other self.submit_other() # if not preflight, save current file if not self.preflight_widget.check.isChecked(): save_file.save_file() # save as next version file save_as.save_as(self.next_version_file) logger.info("Save to %s" % self.next_version_file) # post qc self.submit_post(version_file) # close self and pop a message box to tell that all finished self.close() self.deleteLater() QMessageBox.information(None, "Warming Tip", "Congratulations, QC successful.")
def submit_other(other_dir, files): if not files: return for index, f in enumerate(files): base_name = os.path.basename(f) to_other_path = join_path.join_path2(other_dir, base_name) copy.copy(f, to_other_path)
def copy_image_and_video(context): # copy image and video to publish work_image_path = context.work_image_path work_video_path = context.work_video_path image_path = context.image_path video_path = context.video_path copy.copy(work_image_path, image_path) copy.copy(work_video_path, video_path)
def main(): logger = logging.getLogger(__name__) args = nuke.rawArgs file_name = args[3] context = pipeFile.PathDetails.parse_path(file_name) # copy image and video copy_image_and_video(context) logger.info("Copy image and video done.") # copy to publish publish_path = context.publish_path copy.copy(file_name, publish_path) logger.info("Copy to publish path.")
def package_file(): ar_files = get_all_ar_files() ref_files = get_all_reference_files() all_files = ar_files + ref_files all_files = list(set(all_files)) for f in all_files: if not os.path.isfile(f): print "%s is not an exist file" % f continue driver, suffix = os.path.splitdrive(f) new_path = "%s/%s" % (LOCAL_DIR, suffix) copy.copy(f, new_path) print "copy %s >> %s" % (f, new_path)
def do_export(start, end, path, geos): if os.path.isfile(path): export_abc.export_abc(start, end, path, geos) else: cache_dir, base_name = os.path.split(path) with Temporary(dir_="D:/") as temp_dir: temp_path = "%s/tmp/%s" % (temp_dir, base_name) link_path = "%s/%s" % (temp_dir, base_name) export_abc.export_abc(start, end, temp_path, geos) if os.path.isfile(temp_path) and not os.path.isfile(link_path): os.system('mklink /H "%s" "%s"' % (link_path, temp_path)) copy.copy(link_path, path) else: logger.error("mklink faild")
def export_file_node_textures(tex_dir, change_file_texture_name): file_nodes = mc.ls(type="file") if not file_nodes: return for file_node in file_nodes: texture = mc.getAttr("%s.computedFileTextureNamePattern" % file_node) if not texture: continue texture = texture.replace("\\", "/") if not os.path.splitdrive(texture)[0]: texture = "%s%s" % (mc.workspace(q=1, rootDirectory=1, fullName=1), texture) real_path = get_texture_real_path.get_texture_real_path(texture) if not real_path: continue for each_path in real_path: base_name = os.path.basename(each_path) new_path = join_path.join_path2(tex_dir, base_name) if copy.copy(each_path, new_path): logger.info("Copy %s >> %s" % (each_path, new_path)) if change_file_texture_name: texture_base_name = os.path.basename(texture) new_texture_path = join_path.join_path2(tex_dir, texture_base_name) mc.setAttr("%s.fileTextureName" % file_node, new_texture_path, type="string")
def main(file_name, local): logger = logging.getLogger("Group publish") if not local: open_file.open_file(file_name) # get paths context = pipeFile.PathDetails.parse_path(file_name) # copy image and video publish.copy_image_and_video(context) logger.info("copy image and video done.") # copy to publish path copy.copy(file_name, context.publish_path) logger.info("Copy to publish path.") # generate AD file publish.create_ad(context) logger.info("Create AD done.") # quit maya if not local: quit_maya.quit_maya()
def copy_to_local(self): file_paths = self.work_file_widget.get_selected() if not file_paths: return file_path = file_paths[0] if not os.path.isfile(file_path): return try: obj = pipeFile.PathDetails.parse_path(file_path) local_path = obj.local_work_path copy.copy(file_path, local_path) work_dir = os.path.dirname(os.path.dirname(local_path)) work_engine_dir = join_path.join_path2(work_dir, self.__engine) self.local_file_widget.set_dir(work_engine_dir) self.update_task_status(file_path) self.file_widget.setCurrentIndex(0) except RuntimeError as e: logging.error(str(e))
def main(file_name, local): logger = logging.getLogger("Anim start") new_file.new_file() context = pipeFile.PathDetails.parse_path(file_name) project = context.project sequence = context.sequence shot = context.shot task = "AnimLay" if context.task == "Anim" else context.task lay_publish_file = pipeFile.get_task_publish_file(project, "Shot", sequence, shot, "AnimLay", task) if not os.path.isfile(lay_publish_file): logger.warning("%s is not an exist file" % lay_publish_file) if local: return else: quit_maya.quit_maya() copy.copy(lay_publish_file, file_name) logger.info("copy %s to %s" % (lay_publish_file, file_name)) if local: open_file.open_file(file_name) else: quit_maya.quit_maya()
def main(file_name, local): logger = logging.getLogger("LgtLay publish") if not local: open_file.open_file(file_name) # delete Env try: mc.delete("Env") except: print "Can't delete Env" context = pipeFile.PathDetails.parse_path() publish.copy_image_and_video(context) # export Lights to _light mc.select("Lights", r=1) export_selected.export_selected(context.light_path) logger.info("Export Lights to %s" % context.light_path) # copy to publish path copy.copy(file_name, context.publish_path) logger.info("Copy to publish path") # quit maya if not local: quit_maya.quit_maya()
def copy_to_local(self): file_paths = self.work_stack.list_widget.get_selected() if not file_paths: return file_path = file_paths[0] if not os.path.isfile(file_path): return try: temp_context = pipeFile.PathDetails.parse_path(file_path) next_version_file = temp_context.next_version_file context = pipeFile.PathDetails.parse_path(next_version_file) engine = Step(context.project, context.step).engine local_path = context.local_work_path copy.copy(file_path, local_path) work_dir = os.path.dirname(os.path.dirname(local_path)) work_engine_dir = join_path.join_path2(work_dir, engine) self.local_stack.set_dir(work_engine_dir) self.update_task_status(file_path) self.file_widget.setCurrentIndex(0) except RuntimeError as e: logging.error(str(e))
def on_copy_btn_clicked(self): if not self.sequence: return shots = self.db.get_all_shots(self.sequence) if not shots: return shots = [shot.get("code").split("_")[-1] for shot in shots] shots.sort() self.progress_bar.show() self.progress_bar.setRange(0, len(shots)) for index, shot in enumerate(shots): # project, entity_type, asset_type_sequence, asset_name_shot, step, task, version="" video_file = pipeFile.get_task_workVideo_file(self.project, "Shot", self.sequence, shot, self.step, self.step) if not os.path.isfile(video_file): print "%s is not an exist file" % video_file continue base_name = os.path.basename(video_file) dst_file = "%s/%s/%s/%s" % (DST_DIR, self.sequence, self.step, base_name) copy.copy(video_file, dst_file) print "Copy %s --> %s" % (video_file, dst_file) self.progress_bar.setValue(index+1) self.progress_bar.hide()
def export_single_abc(asset): context = pipeFile.PathDetails.parse_path() mc.parent(asset, world=1) namespace = get_namespace.get_namespace(asset) abc_name = "%s.abc" % namespace abc_path = os.path.join(context.cache_dir, abc_name).replace("\\", "/") start, end = get_frame_range.get_frame_range() meshes = mc.listRelatives(asset, ad=1, type="mesh") geo = [mc.listRelatives(mesh, p=1)[0] for mesh in meshes] objects = list(set(geo)) if os.path.isfile(abc_path): export_exocortex_abc.export_exocortex_abc(abc_path, 950, end, objects) else: cache_dir, base_name = os.path.split(abc_path) with Temporary(dir_="D:/") as temp_dir: temp_path = "%s/tmp/%s" % (temp_dir, base_name) link_path = "%s/%s" % (temp_dir, base_name) export_exocortex_abc.export_exocortex_abc(temp_path, 950, end, objects) if os.path.isfile(temp_path) and not os.path.isfile(link_path): os.system('mklink /H "%s" "%s"' % (link_path, temp_path)) copy.copy(link_path, abc_path) else: print "mklink faild."
def submit_version(self): if self.has_playblast: from miraPipeline.maya.playblast import playblast_turntable, playblast_shot self.playblast_widget.start() try: if self.entity_type == "Asset": playblast_turntable.playblast_turntable() elif self.entity_type == "Shot": playblast_shot.playblast_shot() self.playblast_widget.success() return self.video_path except RuntimeError as e: logger.error(str(e)) self.playblast_widget.fail() else: version_files = self.version_widget.widget.file_list.all_items_text( ) if len(version_files) > 1: QMessageBox.warning(None, "Warming Tip", "Only one file can submit once a time.") self.version_widget.fail() return # if version files, copy to video path, match the ext elif len(version_files) == 1: origin_file = version_files[0] else: return try: ext = os.path.splitext(origin_file)[-1] version_file = "%s%s" % (os.path.splitext( self.video_path)[0], ext) copy.copy(origin_file, version_file) self.version_widget.success() return version_file except: self.version_widget.fail()
def main(): logger = logging.getLogger(__name__) scene_name = get_scene_name.get_scene_name() context = pipeFile.PathDetails.parse_path() asset_name = context.asset_name collection_node = "%s_collection" % asset_name # copy scene and .xgen file to temp dir base_name = os.path.basename(scene_name) xgen_base_name = mc.getAttr("%s.xgFileName" % collection_node) xgen_path = join_path.join_path2(os.path.dirname(scene_name), xgen_base_name) temp_dir = tempfile.gettempdir() maya_temp_file = join_path.join_path2(temp_dir, base_name) xgen_temp_file = join_path.join_path2(temp_dir, xgen_base_name) copy.copy(scene_name, maya_temp_file) copy.copy(xgen_path, xgen_temp_file) logger.info("Copy to temp: %s" % maya_temp_file) # copy local xgen dir to publish. xgen_dir = copy_xgen_dir(context) logger.info("Copy xgen dir to %s" % xgen_dir) # set the path as abs path xgen = Xgen() xgen.set_abs_path(xgen_dir) save_file.save_file() logger.info("Set abs path done.") # copy to work path work_path = context.work_path Copy.copy(scene_name, work_path) Copy.copy(xgen_path, join_path.join_path2(os.path.dirname(work_path), xgen_base_name)) logger.info("copy maya file and .xgen file to workarea done.") # copy from temp file copy.copy(maya_temp_file, scene_name) copy.copy(xgen_temp_file, xgen_path) # delete temp file os.remove(maya_temp_file) os.remove(xgen_temp_file) # open scene name open_file.open_file(scene_name) logger.info("Reopen %s" % scene_name)
def export_rs_normal_map_textures(tex_dir, change_file_texture_name): rs_normal_maps = mc.ls(type="RedshiftNormalMap") if not rs_normal_maps: return for normal_map in rs_normal_maps: texture = mc.getAttr("%s.tex0" % normal_map) if not texture: continue texture = texture.replace("\\", "/") if not os.path.splitdrive(texture)[0]: texture = "%s%s" % (mc.workspace(q=1, rootDirectory=1, fullName=1), texture) real_path = get_texture_real_path.get_texture_real_path(texture) if not real_path: continue for each_path in real_path: base_name = os.path.basename(each_path) new_path = join_path.join_path2(tex_dir, base_name) if copy.copy(each_path, new_path): logger.info("Copy %s >> %s" % (each_path, new_path)) if change_file_texture_name: texture_base_name = os.path.basename(texture) new_texture_path = join_path.join_path2(tex_dir, texture_base_name) mc.setAttr("%s.tex0" % normal_map, new_texture_path, type="string")
def my_copy(src, dst, permission=False): if permission: copy.copy(src, dst) else: Copy.copy(src, dst)