def get_start_py(self): custom_dir = pipeGlobal.custom_dir start_dir = join_path.join_path2(custom_dir, self.project, "start") if not os.path.isdir(start_dir): start_dir = join_path.join_path2(custom_dir, "defaultProject", "start") start_py = join_path.join_path2(start_dir, "start.py") return start_py
def data(self, index, role=Qt.DisplayRole): row = index.row() if role == Qt.DisplayRole: return self.__model_data[row].name if role == Qt.ToolTipRole: publish_path = self.__model_data[row].publish_path if publish_path: obj = pipeFile.PathDetails.parse_path(publish_path) context_version = obj.context_version version = obj.current_version_str if context_version: return "%s\n%s" % (context_version, version) else: return version if role == Qt.DecorationRole: pix_map_path = self.__model_data[row].image_path icon_dir = pipeGlobal.icons_dir if not pix_map_path: pix_map_path = join_path.join_path2(icon_dir, "unknown.png") pix_map = QPixmap(pix_map_path) scaled = pix_map.scaled(QSize(100, 100), Qt.KeepAspectRatio, Qt.SmoothTransformation) scaled.setMask( QBitmap(join_path.join_path2(icon_dir, "round_corner_mask.png"))) return scaled if role == Qt.ForegroundRole: if not self.__model_data[row].publish_path: return QColor(255, 0, 0) else: return QColor(0, 255, 0)
def conf_path(self): conf_path = join_path.join_path2(self.__custom_dir, self.__project, "step.yml") if not os.path.isfile(conf_path): conf_path = join_path.join_path2(self.__custom_dir, "defaultProject", "step.yml") return conf_path
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 get_publish_py(self): custom_dir = pipeGlobal.custom_dir publish_dir = join_path.join_path2(custom_dir, self.project, "publish") if not os.path.isdir(publish_dir): publish_dir = join_path.join_path2(custom_dir, "defaultProject", "publish") publish_py = join_path.join_path2(publish_dir, "publish.py") return publish_py
def __get_conf_path(self, yml_name): conf_path = join_path.join_path2(self.__custom_dir, self.__project, "%s.yml" % yml_name) if not os.path.isfile(conf_path): conf_path = join_path.join_path2(self.__custom_dir, "defaultProject", "%s.yml" % yml_name) return conf_path
def qcpublish(project, step): custom_dir = pipeGlobal.custom_dir qcpublish_dir = join_path.join_path2(custom_dir, project, "QCPublish") if not os.path.isdir(qcpublish_dir): qcpublish_dir = join_path.join_path2(custom_dir, "defaultProject", "QCPublish") fn_, path, desc = imp.find_module(step, [qcpublish_dir]) mod = imp.load_module(step, fn_, path, desc) mod.main()
def nuke_publish(self): custom_dir = pipeGlobal.custom_dir publish_dir = join_path.join_path2(custom_dir, self.project, "publish") if not os.path.isdir(publish_dir): publish_dir = join_path.join_path2(custom_dir, "defaultProject", "publish") publish_py = join_path.join_path2(publish_dir, "%s.py" % self.context.step) if not os.path.isfile(publish_py): self.logger.error("%s is not an exist file" % publish_py) return nuke_path = Project(self.context.project).nuke_path cmd = "%s -t %s %s" % (nuke_path, publish_py, self.work_file) self.run_command(cmd) self.post_publish()
def get_logger(project, logger_type, task_name): logger_dir = Project(project).task_log_dir logger_dir = logger_dir.format(project=project) logger_dir = join_path.join_path2(logger_dir, logger_type) if not os.path.isdir(logger_dir): os.makedirs(logger_dir) current_time = time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()) file_base_name = "%s-%s.txt" % (task_name, current_time) file_name = join_path.join_path2(logger_dir, file_base_name) logging.basicConfig(filename=file_name, level=logging.DEBUG, filemode='w', format='%(asctime)s - %(levelname)s: %(message)s') logger = logging.getLogger() return logger
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 setup_ui(self): main_layout = QVBoxLayout(self) main_layout.setContentsMargins(0, 2, 0, 0) top_layout = QHBoxLayout() self.select_check = QCheckBox("Select in Maya") self.select_check.setChecked(True) self.filter_le = Filter() self.filter_le.setPlaceholderText("Search...") self.update_btn = QToolButton() icon_path = join_path.join_path2(pipeGlobal.icons_dir, "update.png") self.update_btn.setIcon(QIcon(icon_path)) self.update_btn.setStyleSheet( "QToolButton{background:transparent;border: 0px;}" "QToolButton::hover{background:#AAAAAA;}") top_layout.addWidget(self.select_check) top_layout.addStretch() top_layout.addWidget(self.filter_le) top_layout.addWidget(self.update_btn) self.tree_view = QTreeView() btn_layout = QHBoxLayout() self.replace_btn = QPushButton("Replace") self.replace_btn.setFixedHeight(30) btn_layout.addWidget(self.replace_btn) # main_layout.addLayout(top_layout) main_layout.addWidget(self.tree_view)
def set_widget_dir(self, stack_widget, file_path): if file_path: file_dir = os.path.dirname(os.path.dirname(file_path)) if self.__engine != "python": engine = Step(self.selected.project, self.selected.step).engine file_dir = join_path.join_path2(file_dir, engine) stack_widget.set_dir(file_dir)
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 __init__(self, icon_file=None, parent=None): super(Filter, self).__init__(parent) self.icon_file = icon_file if not self.icon_file: icon_dir = pipeGlobal.icons_dir self.icon_file = join_path.join_path2(icon_dir, "search.png") self.button = QToolButton(self) self.button.setEnabled(False) self.button.setIcon(QIcon(self.icon_file)) self.button.setStyleSheet("QToolButton{border: 0px; padding: 0px; background:transparent}"\ "QToolButton::hover{background:transparent}") self.button.setCursor(Qt.ArrowCursor) self.button.clicked.connect(self.editingFinished) frame_width = self.style().pixelMetric(QStyle.PM_DefaultFrameWidth) button_size = self.button.sizeHint() self.setStyleSheet('QLineEdit {padding-right: %dpx; }' % (button_size.width() + frame_width + 1)) self.setMinimumSize( max(self.minimumSizeHint().width(), button_size.width() + frame_width * 2 + 2), max(self.minimumSizeHint().height(), button_size.height() + frame_width * 2 + 2))
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) shutil.copy(scene_name, temp_file) logger.info("Copy to temp: %s" % temp_file) # copy all textures to _tex # if modified, backup it 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 obj = pipeFile.PathDetails.parse_path() project = obj.project QCPublish_path = obj.QCPublish_path backup.backup(project, scene_name) Copy.copy(scene_name, QCPublish_path) logger.info("copy %s >> %s" % (scene_name, QCPublish_path)) # copy from temp file shutil.copy(temp_file, scene_name) # delete temp file os.remove(temp_file) # open scene name open_file.open_file(scene_name) logger.info("Reopen %s" % scene_name)
def get_proxy_dir(): obj = pipeFile.PathDetails.parse_path() project = obj.project asset_name = obj.asset_name root_dir = pipeMira.get_root_dir(project) proxy_dir = join_path.join_path2(root_dir, project, "assets", "proxy", asset_name, "static") return proxy_dir
def qcpublish(step): script_dir = pipeGlobal.pipeline_dir publish_dir = join_path.join_path2(script_dir, "maya", "QCPublish") if publish_dir not in sys.path: sys.path.insert(0, publish_dir) step_publish = "{0}_qcpublish".format(step) cmd_text = "import {0}; reload({0}); {0}.{0}()".format(step_publish) exec(cmd_text)
def on_item_clicked(self, index): node = self.proxy_model.mapToSource(index).internalPointer() self.selected = node if node.node_type != "task": return entity_type = node.entity_type asset_type_sequence = node.parent().name asset_name_shot = node.name.split("_")[-1] step = node.step task = node.task status = node.status status_color = node.status_color due_date = node.due_date # show path local_file = pipeFile.get_task_work_file(self.project, entity_type, asset_type_sequence, asset_name_shot, step, task, "000", local=True) work_file = pipeFile.get_task_work_file(self.project, entity_type, asset_type_sequence, asset_name_shot, step, task, "000") publish_file = pipeFile.get_task_publish_file(self.project, entity_type, asset_type_sequence, asset_name_shot, step, task, "000") local_dir = os.path.dirname(os.path.dirname(local_file)) work_dir = os.path.dirname(os.path.dirname(work_file)) publish_dir = os.path.dirname(os.path.dirname(publish_file)) if self.__engine != "python": local_dir = join_path.join_path2(local_dir, self.__engine) work_dir = join_path.join_path2(work_dir, self.__engine) publish_dir = join_path.join_path2(publish_dir, self.__engine) self.local_file_widget.set_dir(local_dir) self.work_file_widget.set_dir(work_dir) self.publish_file_widget.set_dir(publish_dir) # show status and due_date self.status_label.setText("<font size=4 color=%s><b>%s</b></font>" % (status_color, status)) self.due_label.setText("<font size=4 color=#ff8c00>%s</font>" % due_date)
def setup_ui(self): main_layout = QVBoxLayout(self) main_layout.setContentsMargins(0, 0, 0, 0) proxy_filter_layout = QHBoxLayout() self.filter_le = Filter() proxy_filter_layout.addStretch() proxy_filter_layout.addWidget(self.filter_le) self.update_btn = QToolButton() icon_path = join_path.join_path2(pipeGlobal.icons_dir, "update.png") self.update_btn.setIcon(QIcon(icon_path)) self.update_btn.setStyleSheet( "QToolButton{background:transparent;}" "QToolButton::hover{background:#00BFFF;border-color:#00BFFF;}") proxy_filter_layout.addWidget(self.update_btn) self.table_view = QTableView() self.table_view.verticalHeader().hide() self.table_view.horizontalHeader().setStretchLastSection(True) self.table_view.setSortingEnabled(True) self.table_view.setAlternatingRowColors(True) self.table_view.setSelectionBehavior(QAbstractItemView.SelectRows) btn_layout = QHBoxLayout() self.switch_btn = QPushButton("Switch") self.cancel_btn = QPushButton("Cancel") btn_layout.addStretch() btn_layout.addWidget(self.switch_btn) btn_layout.addWidget(self.cancel_btn) # --filter layout filter_layout = QHBoxLayout() filter_layout.setContentsMargins(0, 0, 0, 0) filter_group = QGroupBox() filter_layout.addWidget(filter_group) check_layout = QHBoxLayout(filter_group) check_layout.setContentsMargins(3, 1, 0, 1) filter_label = QLabel("Filters") self.check_btn_group = QButtonGroup() self.check_btn_group.setExclusive(False) self.green_check = QCheckBox() self.green_check.setChecked(True) self.green_check.setIcon(QIcon(self.green_icon_path)) self.red_check = QCheckBox() self.red_check.setChecked(True) self.red_check.setIcon(QIcon(self.red_icon_path)) check_layout.addWidget(filter_label) check_layout.addWidget(self.green_check) check_layout.addWidget(self.red_check) self.check_btn_group.addButton(self.green_check) self.check_btn_group.addButton(self.red_check) bottom_layout = QHBoxLayout() bottom_layout.addLayout(filter_layout) bottom_layout.addStretch() bottom_layout.addLayout(btn_layout) main_layout.addLayout(proxy_filter_layout) main_layout.addWidget(self.table_view) main_layout.addLayout(bottom_layout)
def set_hair_textures(tex_dir): hair_file_nodes = get_all_hair_file_node.get_all_hair_file_node() if not hair_file_nodes: return for file_node in hair_file_nodes: texture = mc.getAttr("%s.fileTextureName" % file_node) base_name = os.path.basename(texture) new_path = join_path.join_path2(tex_dir, base_name) mc.setAttr("%s.fileTextureName" % file_node, new_path, type="string")
def get_buttons(): # get conf path conf_dir = pipeGlobal.conf_dir shelf_conf_path = join_path.join_path2(conf_dir, "maya_shelf.yml") shelf_conf_data = yml_operation.get_yaml_data(shelf_conf_path) pipeline_shelf = shelf_conf_data["pipeline_shelf"] pipeline_buttons = sorted(pipeline_shelf, key=lambda key: pipeline_shelf[key]["order"]) return pipeline_buttons
def publish_textures(tex_dir): all_textures = get_all_textures() all_textures = list(set(all_textures)) if not all_textures: return for tex in all_textures: base_name = os.path.basename(tex) new_path = join_path.join_path2(tex_dir, base_name) Copy.copy(tex, new_path)
def run(self): default_image_path = join_path.join_path2(self.__image_dir, "unknown.png") if self.__show_image: project_data = Project(self.__project) primary = project_data.primary if self.__entity_type == "Asset": format_str = project_data.template("maya_asset_image") step = "MidMdl" task = "MidMdl" else: format_str = project_data.template("maya_shot_image") step = "AnimLay" task = "AnimLay" engine = Step(self.__project, step).engine for entity in self.__entities: entity_name = entity.get("code") image_path = format_str.format( primary=primary, project=self.__project, asset_type=self.__asset_type_sequence, sequence=self.__asset_type_sequence, asset_name=entity_name, shot=entity_name.split("_")[-1], step=step, task=task, engine=engine) if self.__entity_type == "Asset" and not os.path.isfile( image_path): image_path = format_str.format( primary=primary, project=self.__project, asset_type=self.__asset_type_sequence, asset_name=entity_name, step="Group", task="Group", engine=engine) if self.__entity_type == "Shot" and not os.path.isfile( image_path): image_path = format_str.format( primary=primary, project=self.__project, sequence=self.__asset_type_sequence, shot=entity_name.split("_")[-1], step="Set", task="Set", engine=engine) if not os.path.isfile(image_path): image_path = default_image_path self.__collect_data.append([entity_name, image_path]) else: for entity in self.__entities: entity_name = entity.get("code") self.__collect_data.append([entity_name, default_image_path]) self.signal.emit(self.__collect_data)
def main(): # delete shelf top_shelf = pm.melGlobals['gShelfTopLevel'] # get buttons from yml pipeline_buttons = get_buttons() # create shelf maya_shelf_opt.delete_shelf(top_shelf, "PipeLine") maya_shelf_opt.create_shelf(top_shelf, "PipeLine") # get icon dir icon_dir = pipeGlobal.icons_dir shelf_icon_dir = join_path.join_path2(icon_dir, "maya_shelf_buttons") # create buttons sys.path.insert(0, os.path.dirname(__file__)) for button in pipeline_buttons: cmd_text = "import {0}; reload({0}); {0}.main()".format(button) btn_command = functools.partial(exec_cmd, cmd_text) icon_path = join_path.join_path2(shelf_icon_dir, "%s.png" % button) maya_shelf_opt.create_shelf_button(button, "PipeLine", btn_command, icon_path)
def back_up_textures(backup_tex_dir, file_path, scene_version=None): file_path = file_path.replace("\\", "/") logger = logging.getLogger(__name__) if not os.path.isfile(file_path): logger.warning("%s is not an exist file." % file_path) return base_name = os.path.basename(file_path) backup_file = join_path.join_path2(backup_tex_dir, base_name) if not os.path.isfile(backup_file): Copy.copy(file_path, backup_file) logger.info("backup %s >> %s" % (file_path, backup_file)) else: if not filecmp.cmp(file_path, backup_file): base_name = os.path.basename(backup_file) version_str = "v" + str(scene_version).zfill(3) s_base_name, ext = os.path.splitext(base_name) new_base_name = "%s_%s%s" % (s_base_name, version_str, ext) new_backup_file = join_path.join_path2(backup_tex_dir, new_base_name) Copy.copy(file_path, new_backup_file) logger.info("backup %s >> %s" % (file_path, new_backup_file))
def do_start(self): if not self.work_file: return start_script_path = join_path.join_path2(__file__, "..", "start.py") obj = pipeFile.PathDetails.parse_path(self.work_file) task_name = get_task_name(obj) deadline_job_name = "start_%s" % task_name # work_file, change_task argv = self.work_file white_list = 'pipemanager' submit_python.submit_python(start_script_path, argv, white_list, deadline_job_name) QMessageBox.information(self, "Warming Tip", "%s submit done." % task_name)
def add_env_assets(self): self.asset_cbox.clear() root_dir = pipeMira.get_root_dir(self.current_project) env_dir = join_path.join_path2(root_dir, self.current_project, "assets", "proxy") if not os.path.isdir(env_dir): return env_assets = os.listdir(env_dir) if not env_assets: return self.asset_cbox.addItems(env_assets) self.asset_cbox.setCurrentIndex(self.asset_cbox.count() + 1)
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 start_from_task_path(work_file): pipeline_dir = miraCore.get_pipeline_dir() start_script_path = join_path.join_path2(pipeline_dir, "pipeline", "task_start", "start.py") obj = pipeFile.PathDetails.parse_path(work_file) task_name = get_task_name(obj) deadline_job_name = "start_%s" % task_name # work_file, change_task argv = work_file submitter = u'pipemanager' tar_name = u'pipemanager' submit.submit_python_job(deadline_job_name, start_script_path, argv, submitter, tar_name)
def do_submit(self): files = self.file_list.all_items_text() if not files: self.close() return self.progress_bar.show() self.progress_bar.setRange(0, len(files)) for index, f in enumerate(files): base_name = os.path.basename(f) to_other_path = join_path.join_path2(self.other_dir, base_name) Copy.copy(f, to_other_path) self.progress_bar.setValue(index + 1) self.close()