def refresh(self, *_): if config.getProject(): self.setCurrentText(config.getProject()) elif config.getProject(all=True): self.setCurrentIndex(-1) return else: return
def refreshUI(self, *_): self.reset() if not config.getProject(): return self.project = config.getConfig("database") self.onTaskListChanged()
def submit(self, *_): if not database.getAccountInfo(database.ACCOUNT_LOGGED_IN): self.reset() return import pyblish_starter.api as api index = self.CGTWTVTask.currentIndex() task_id = index.data(model.TASK_ID) family = index.data(model.TASK_STAGE) name = index.data(model.TASK_NAME) if family not in config.getConfig("familyMap"): self.CGTWLBLResult.setText(u"<font color=black>所选任务不能在Maya中执行</font>") self.CGTWLBLResult.setStyleSheet("background-color: rgba(255, 255, 90, 255);") return self.CGTWLBLResult.setText(u"<font color=black>正在提交检查...</font>") self.CGTWLBLResult.setStyleSheet("background-color: rgba(90, 255, 255, 255);") try: cmds.delete("%s_SEL"%name) except: pass api.registered_host().create(name, config.getConfig("familyMap")[family]) cmds.addAttr("%s_SEL"%name, longName="project", dataType="string", hidden=False) cmds.addAttr("%s_SEL"%name, longName="pipeline", dataType="string", hidden=False) cmds.addAttr("%s_SEL"%name, longName="database", dataType="string", hidden=False) cmds.addAttr("%s_SEL"%name, longName="taskID", dataType="string", hidden=False) cmds.setAttr("%s_SEL.project"%name, config.getProject(), type="string") cmds.setAttr("%s_SEL.pipeline"%name, family, type="string") cmds.setAttr("%s_SEL.database"%name, config.getConfig("database"), type="string") cmds.setAttr("%s_SEL.taskID"%name, task_id, type="string") context = pyblish.util.publish() self.CGTWLBLResult.setText(u"<font color=black>任务提交成功</font>") self.CGTWLBLResult.setStyleSheet("background-color: rgba(90, 255, 90, 255);") for result in context.data["results"]: if not result["success"]: self.CGTWLBLResult.setText(u"<font color=black>错误:%s</font>"%result["error"].message) self.CGTWLBLResult.setStyleSheet("background-color: rgba(255, 90, 90, 255);") break cmds.delete("%s_SEL"%name)
def refreshCharacters(self, *_): if not config.getProject(): return cmds.namespace(set=":") chars = self.getCharacters() if getattr(self, 'chars', None) and self.chars == chars: return self.chars = chars self.motionLibTab.setVisible(bool(chars)) while self.motionLibCBCharactor.count(): self.motionLibCBCharactor.removeItem(0) charsDic = {} for char in chars: charsDic[char] = "%s <%s>" % (self.getOrigChar( char.split(":")[-1]).split("C_")[-1], char) self.motionLibCBCharactor.addItem(charsDic[char]) try: self.motionLibCBCharactor.setCurrentIndex( self.motionLibCBCharactor.findText(charsDic[self.namespace])) except: pass self.refreshData()
def refreshData(self, *_): self.__select = [] cmds.namespace(set=":") self.shelf.cleanUp() self.motionLibBtnImport.setEnabled(False) self.motionLibCBProject.setCurrentText(config.getProject()) if not self.motionLibCBCharactor.count(): return self.namespace = self.motionLibCBCharactor.currentText().split( "<")[-1].split(">")[0] self.path = config.getConfig('animLibPath') + self.getOrigChar( self.namespace.split(":")[-1]) fileList = self.getFileList(self.path) exp = codecs.decode(self.motionLibLEFilter.text(), 'utf-8') itemList = [] for f in fileList: if self.__match__(f, exp): found = False for ext in ['gif', 'png', 'jpg']: iconPath = self.path + f + ext if os.path.isfile(iconPath): found = True break if not found: iconPath = config.getPath(config.kIcon, "motion.gif") itemList.append({ ui.QShelfView.kName: f, ui.QShelfView.kData: f, ui.QShelfView.kIcon: iconPath, ui.QShelfView.kType: f }) self.shelf.setup(*itemList) sels = os.popen("type \"%s\"\\__config__" % self.path).read() for sel in sels.split('&'): if not sel: continue self.__select.append("%s:%s" % (self.namespace, sel)) if not self.__select: self.__select.append("%s:Main" % self.namespace) cmds.select(self.__select, r=True) self.__config = None