def listSgTasks(self, in_sStepCodes=None, fail=False, moreFields=None, moreFilters=None): sStepCodes = argToTuple(in_sStepCodes) proj = self.project sgEntity = self.getSgInfo() sgSteps = None if sStepCodes: sgSteps = self.getSgSteps(*sStepCodes) sgTaskList = proj._shotgundb.getTasks(sgEntity, sgSteps, moreFields=moreFields, moreFilters=moreFilters) if (not sgTaskList) and fail: if sStepCodes: msg = ("<{}> No Shotgun Tasks found for given steps: {}" .format(self, ", ".join(sStepCodes))) else: msg = "<{}> No Shotgun Task defined !".format(self) raise ValueError(msg) #sgTaskList.sort(key=lambda t:t['step']['list_order']) return sgTaskList
def listMissingPathItems(proj, entityType=""): shotgundb = proj._shotgundb sg = shotgundb.sg missingPathItems = [] if not entityType: sEntityTypes = ("asset", "shot") else: sEntityTypes = argToTuple(entityType) bAssets = "asset" in sEntityTypes bShots = "shot" in sEntityTypes if bAssets: sSectionList = [] confobj = proj._confobj for sSection, _ in confobj.listSections(): if not confobj.getVar(sSection, "template_dir", ""): continue sSectionList.extend(confobj.getVar(sSection, "aliases", ())) filters = [["project", "is", {"type":"Project", "id":shotgundb._getProjectId()}], ["sg_status_list", "is_not", "omt"], ["sg_asset_type", "in", sSectionList]] allSgAstList = sg.find("Asset", filters, ["code", "sg_asset_type", "sg_status_list"], [{'field_name':'sg_asset_type', 'direction':'asc'}, {'field_name':'code', 'direction':'asc'}]) # allSgAstList.append({"code":"chfjhgrjlkhdjtr"}) print "Assets:", len(allSgAstList) if bShots: filters = [["project", "is", {"type":"Project", "id":shotgundb._getProjectId()}], ["sg_status_list", "is_not", "omt"], ["sg_sequence", "is_not", None], ["sg_sequence.Sequence.sg_status_list", "is_not", "omt"] ] allSgShotList = sg.find("Shot", filters, ["code", "sg_sequence", "sg_status_list"], [{'field_name':'sg_sequence', 'direction':'asc'}, {'field_name':'code', 'direction':'asc'}]) print "Shots:", len(allSgShotList) if bAssets: missingPathItems = list(iterMissingPathItems(proj, "asset", allSgAstList)) if bShots: missingPathItems.extend(iterMissingPathItems(proj, "shot", allSgShotList)) return missingPathItems
def _iterLibrariesSpaceAndSection(self, space=LIBRARY_SPACES, fullName=False): sSpaceList = argToTuple(space) for sLibSection in self.__confLibraries: for sSpace in sSpaceList: if fullName: yield DrcLibrary.makeFullName(sSpace, sLibSection) else: yield (sSpace, sLibSection)
def createInputDataUI(self, parentWidget, **kwargs): cls = self.__class__ logMsg(cls.__name__, log='all') sIgnorePrpty = kwargs.pop("ignoreInputData", []) sIgnorePrptyList = argToTuple(sIgnorePrpty) inputWdgItems = [] for sProperty, _ in cls.propertiesDctItems: if sProperty in sIgnorePrptyList: continue metaprpty = self.__metaProperties[sProperty] if metaprpty.isInput(): inputWdg = metaprpty.createEditorWidget(parentWidget) inputWdgItems.append((metaprpty.name , { "widget" : inputWdg })) return inputWdgItems
def createInputDataUI(self, parentWidget, **kwargs): cls = self.__class__ logMsg(cls.__name__, log='all') sIgnorePrpty = kwargs.pop("ignoreInputData", []) sIgnorePrptyList = argToTuple(sIgnorePrpty) inputWdgItems = [] for sProperty, _ in cls.propertiesDctItems: if sProperty in sIgnorePrptyList: continue metaprpty = self.__metaProperties[sProperty] if metaprpty.isInput(): inputWdg = metaprpty.createEditorWidget(parentWidget) inputWdgItems.append((metaprpty.name, {"widget": inputWdg})) return inputWdgItems
def pruneNodeList(in_nodeList, **kwargs): if not in_nodeList: return in_nodeList seqType = type(in_nodeList) nodeList = argToTuple(in_nodeList) _mod = mc if isinstance(nodeList[0], basestring) else pm for kwarg, value in kwargs.iteritems(): if not value: continue junkNodes = set(_mod.ls(nodeList, **{kwarg:value})) if junkNodes: nodeList = tuple(n for n in nodeList if n not in junkNodes) return seqType(nodeList)
def chooseMayaScene(**kwargs): fileFilters = kwargs.pop("fileFilter", kwargs.pop("ff", "mayaScene")) sFileFilters = argToTuple(fileFilters) sFilterDct = { "mayaScene":"Maya Scenes (*.ma *.mb)", "mayaAscii": "Maya ASCII (*.ma)", "mayaBinary": "Maya Binary (*.mb)", } sFileFilters = tuple(sFilterDct.get(ff, ff) for ff in sFileFilters) sFileFilter = ";;".join(sFileFilters) sSelFilter = kwargs.pop("selectFileFilter", kwargs.pop("sff", sFileFilters[0])) kwargs.pop("dialogStyle", kwargs.pop("ds", 2)) return pm.fileDialog2(fileFilter=sFileFilter, dialogStyle=2, selectFileFilter=sSelFilter, **kwargs)
def _iterOutOfSyncFiles(proj, libraries=None, limit=0): if libraries: libraries = argToTuple(libraries) pubLibs = tuple(l for l in proj.loadedLibraries.itervalues() if l.isPublic() and (l.sectionName in libraries)) else: pubLibs = tuple(l for l in proj.loadedLibraries.itervalues() if l.isPublic()) for pubLib in pubLibs: dbNodeList = pubLib.loadChildDbNodes(recursive=True, noVersions=True) #print pubLib, len(dbNodeList) numDbNodes = len(dbNodeList) c = 0 for dbnode in dbNodeList: c += 1 if limit and c == limit: break print "Processing {}/{} db nodes from {}".format(c, numDbNodes, pubLib) sDbPath = dbnode.file if sDbPath.endswith("/"): continue sAbsPath = pubLib.dbToAbsPath(sDbPath) drcFile = pubLib.getEntry(sAbsPath) if not drcFile: print "No such file: '{}'".format(sAbsPath) continue if not drcFile.isUpToDate(refresh=False): yield drcFile
def chooseMayaScene(**kwargs): fileFilters = kwargs.pop("fileFilter", kwargs.pop("ff", "mayaScene")) sFileFilters = argToTuple(fileFilters) sFilterDct = { "mayaScene": "Maya Scenes (*.ma *.mb)", "mayaAscii": "Maya ASCII (*.ma)", "mayaBinary": "Maya Binary (*.mb)", } sFileFilters = tuple(sFilterDct.get(ff, ff) for ff in sFileFilters) sFileFilter = ";;".join(sFileFilters) sSelFilter = kwargs.pop("selectFileFilter", kwargs.pop("sff", sFileFilters[0])) kwargs.pop("dialogStyle", kwargs.pop("ds", 2)) return pm.fileDialog2(fileFilter=sFileFilter, dialogStyle=2, selectFileFilter=sSelFilter, **kwargs)
def setSyncRulesToDefault(proj, entityType="", dryRun=True, includeOmitted=False, filters=None, fields=None): syncedPathItems = [] if not entityType: sEntityTypes = ("asset", "shot") else: sEntityTypes = argToTuple(entityType) bAssets = "asset" in sEntityTypes bShots = "shot" in sEntityTypes if bAssets: allSgAstList = proj.listAllSgAssets(includeOmitted=includeOmitted, moreFilters=filters, moreFields=fields) # allSgAstList.append({"code":"chfjhgrjlkhdjtr"}) print "Assets:", len(allSgAstList) if bShots: allSgShotList = proj.listAllSgShots(includeOmitted=includeOmitted, moreFilters=filters, moreFields=fields) print "Shots:", len(allSgShotList) if bAssets: syncedPathItems = list(iterSyncedResource(proj, "asset", allSgAstList)) if bShots: syncedPathItems.extend(iterSyncedResource(proj, "shot", allSgShotList)) grpIter = groupby(syncedPathItems, key=lambda x:x[0].parentEntity()) for k, grp in grpIter: damEntity = next(grp)[0] parentDir = damEntity.getResource("public", dbNode=False, weak=True).parentDir() print "loading DbNodes for '{}'".format(k) parentDir.loadChildDbNodes(recursive=True, noVersions=True) rcRuleItems = [] for damEntity, sAbsPath, sSyncRuleList in syncedPathItems: rcEntry = damEntity.getLibrary().getEntry(sAbsPath, dbNode=False) #print rcEntry, sAbsPath, damEntity, rcEntry.syncRules if not rcEntry: continue rcEntry.syncRules = sorted(str(u) for u in rcEntry.syncRules) if rcEntry.syncRules == sSyncRuleList: continue sTime = toDisplayText(rcEntry.dbMtime) # sTime = "" # dbNode = rcEntry._dbnode # if dbNode: # sTime = toDisplayText(datetime.fromtimestamp(dbNode.time / 1000)) print rcEntry.relPath(), rcEntry.syncRules, sSyncRuleList, sTime rcRuleItems.append((rcEntry, sSyncRuleList)) # if not dryRun: # rcEntry.setSyncRules(sSyncRuleList) return rcRuleItems