def onHistoryItemDoubleClicked(self, index): if not database.getAccountInfo(database.ACCOUNT_LOGGED_IN): self.reset() return path = index.data(model.FILE_PATH).replace('/', '\\') self.open(path)
def cmd_getconfig(data): if 'cacheid' in data: device = database.getDeviceId(data['cacheid']) email = database.getDeviceAccount(device) elif 'token' in data: email = database.verifyToken(data['token']) else: email = None if email is None: return { 'config': None, 'characters': None, } info = database.getAccountInfo(email) chars = {} for slot in database.getSlots(email): prof = database.getProfile(email, slot['id']) if prof: c = prof.get('character') if c is not None: chars[slot['id']] = c return { 'config': info['config'], 'characters': chars, }
def onFilterChanged(self, *_): if not database.getAccountInfo(database.ACCOUNT_LOGGED_IN): self.reset() return tag = self.CGTWCBFilter.currentText() self.CGTWTVAll.model().setFilterFixedString(tag)
def cmd_newslot(data): email = database.verifyToken(data['token']) if not email: return needlogin() info = database.getAccountInfo(email) config = info['config'] id = 1 for slot in config['slots']: if slot['id'] >= id: id = slot['id'] + 1 newslot = { 'id': id, 'name': 'New Student', 'group': '', 'active': True, } config['slots'].append(newslot) database.setAccountInfo(email, info) return { 'newslot': newslot, }
def onLinkItemDoubleClicked(self, index): if not database.getAccountInfo(database.ACCOUNT_LOGGED_IN): self.reset() return file_name = index.data() file_path = index.model().rootPath().replace('/', '\\') self.open(os.path.join(file_path, file_name))
def reset(self): self.clear() self.CGTWTVTask.model().clear() self.CGTWTVCheck.model().clear() self.CGTWTVAll.model().sourceModel().clear() self.tabWidget.setEnabled(database.getAccountInfo(database.ACCOUNT_LOGGED_IN)) self.CGTWBtnRefresh.setEnabled(database.getAccountInfo(database.ACCOUNT_LOGGED_IN)) self.CGTWGBInfo.setEnabled(database.getAccountInfo(database.ACCOUNT_LOGGED_IN)) self.CGTWLEUsername.setVisible(not database.getAccountInfo(database.ACCOUNT_LOGGED_IN)) self.CGTWLEPassword.setVisible(not database.getAccountInfo(database.ACCOUNT_LOGGED_IN)) self.CGTWBtnConnect.setVisible(not database.getAccountInfo(database.ACCOUNT_LOGGED_IN)) self.CGTWLEDeregister.setVisible(database.getAccountInfo(database.ACCOUNT_LOGGED_IN)) if database.getAccountInfo(database.ACCOUNT_LOGGED_IN): self.id = database.getAccountInfo() self.CGTWLBLUser.setText(u"欢迎,%s" % database.getAccountInfo(database.ACCOUNT_NAME)) else: self.id = "" self.CGTWLBLUser.setText(u"请登录...")
def onFileboxChanged(self, index): if not database.getAccountInfo(database.ACCOUNT_LOGGED_IN): self.reset() return path = self.CGTWCBFileLink.itemData(index, model.FILE_PATH) if not path: return self.CGTWLVFileLink.setRootIndex(self.CGTWLVFileLink.model().index(path)) self.CGTWLVFileLink.model().setRootPath(path) self.CGTWLVFileLink.model().setFilter(QtCore.QDir.Files)
def cmd_setprofilemode(data): email = database.verifyToken(data['token']) if not email: return needlogin() assert data['mode'] in ('list', 'groups') info = database.getAccountInfo(email) info['config']['profile_mode'] = data['mode'] database.setAccountInfo(email, info) return {}
def cmd_login(data): if 'token' in data: email = database.verifyToken(data['token']) if email: info = database.getAccountInfo(email) return {'token': data['token'], 'info': info} else: return { 'error': 'login', 'msg': 'Token invalid or expired. Please log in again.' } email = data['email'] pwd = data['password'] if database.verifyLogin(email, pwd): token = database.createToken(email) info = database.getAccountInfo(email) return {'token': token, 'info': info} return {'error': 'login', 'msg': 'Incorrect username or password.'}
def onFileChanged(self, *_): if not database.getAccountInfo(database.ACCOUNT_LOGGED_IN): self.reset() return task_id = self.getCurrentTaskInfo(model.TASK_ID) task_stage = self.getCurrentTaskInfo(model.TASK_STAGE) file_name = self.CGTWCBFile.currentText() self.CGTWTVFileHistory.model().update(task_id, task_stage, file_name) self.CGTWTVFileHistory.setColumnWidth(0, 200) self.CGTWTVFileHistory.setColumnWidth(1, 160) self.CGTWTVFileHistory.setColumnWidth(2, 50) self.CGTWTVFileHistory.setColumnWidth(3, 50)
def onTaskChanged(self, *_): if not database.getAccountInfo(database.ACCOUNT_LOGGED_IN): self.reset() return self.clear() task_id = self.getCurrentTaskInfo(model.TASK_ID) if not task_id: return task_stage = self.getCurrentTaskInfo(model.TASK_STAGE) task_name = self.getCurrentTaskInfo(model.TASK_NAME) task_status = self.getCurrentTaskInfo(model.TASK_STATUS) task_detail = self.getCurrentTaskInfo(model.TASK_DETAIL) status_color_map = {"Retake": "background-color: rgba(255, 90, 90, 255);", "Check": "background-color: rgba(255, 255, 90, 255);", "Approve": "background-color: rgba(90, 255, 90, 255);", "FinalApprove": "background-color: rgba(90, 255, 90, 255);"} status_text_map = {"Retake": "[被回退] ", "Check": "[等待检查] ", "Approve": "[已发布] ", "FinalApprove": "[已发布] "} task_history = database.getFileHistoryInfo(task_id) self.CGTWBtnSubmit.setEnabled(self.tabWidget.currentIndex() == 0) self.CGTWBtnRetake.setEnabled(self.tabWidget.currentIndex() == 1) self.CGTWBtnFinal.setEnabled(self.tabWidget.currentIndex() == 1) self.CGTWGBInfo.setTitle(task_name) self.CGTWLBLInfoType.setText(task_detail) if task_history and task_status in status_color_map: self.CGTWLBLStatus.setStyleSheet(status_color_map[task_status]) #self.CGTWLBLStatus.setText(u"<font color=black>%s%s</font>"% # (status_text_map[task_status], # self.extractText(task_history[0]["text"]))) self.CGTWCBFile.model().update(task_id) publish_dir = self.CGTWCBFileLink.model().update(task_id, task_stage) if not publish_dir: return publish_path = os.path.join(publish_dir, "%s.ma"%task_name) if os.path.isfile(publish_path): self.CGTWBtnRefer.setEnabled(True) self.reference = publish_path self.namespace = task_name
def onTaskListChanged(self, *_): if not database.getAccountInfo(database.ACCOUNT_LOGGED_IN): self.reset() return self.clear() index = self.tabWidget.currentIndex() table = "asset" if self.CGTWRBAsset.isChecked() else "shot" view_list = [self.CGTWTVTask, self.CGTWTVCheck, self.CGTWTVAll] view_expand = [True, True, False] treeView = view_list[index] treeView.model().update(table) treeView.setColumnWidth(0, 275) treeView.update(treeView.currentIndex()) if view_expand[index]: treeView.expandAll()
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 cmd_changeslot(data): email = database.verifyToken(data['token']) if not email: return needlogin() info = database.getAccountInfo(email) config = info['config'] if 'name' in data: assert type(data['name']) == str if 'group' in data: assert type(data['group']) == str if 'active' in data: assert type(data['active']) == bool for slot in config['slots']: if slot['id'] == data['id']: for key in ('name', 'group', 'active'): if key in data: slot[key] = data[key] database.setAccountInfo(email, info) return {}