def setProject(self, *args, **kwargs): try: return self.browserWidget.setProject(*args, **kwargs) except Exception, err: confirmDialog(title='SORRY !' , message=toStr(err) , button=["OK"] , defaultButton="OK" , cancelButton="OK" , dismissString="OK" , icon="critical") if not hostApp(): os.environ["PYTHONINSPECT"] = "1" self.close() raise # def __del__(self): # print "__del__", self.objectName() # def closeEvent(self, event): # print self, "closeEvent" # return QtGui.QMainWindow.closeEvent(self, event)
def doPublish(self, *itemList): item = itemList[-1] pubEntry = item._metaobj proj = self.model()._metamodel if isinstance(pubEntry, DrcFile): try: pubEntry.assertFreeToPublish() except EnvironmentError as e: confirmDialog(title='SORRY !', message="Publishing not allowed:\n\n" + toStr(e), button=["OK"], icon="critical") return sAbsPath = pubEntry.absPath() if proj.isEditableResource(sAbsPath): if hostApp() == "maya": sExt = osp.splitext(sAbsPath)[-1] if sExt in (".ma", ".mb"): raise EnvironmentError("Please, publish from integrated 'Davos' menu.") self.__publishEditedVersion(pubEntry) else: self.__publishRegularVersion(pubEntry) else: self.__publishFiles(pubEntry)
def importFiles(self, *itemList): proj = self.model()._metamodel try: if not hostApp(): raise AssertionError("You can only import from inside another application.") drcFileList = tuple(item._metaobj for item in itemList) if len(drcFileList) > 1: for drcFile in drcFileList: try: drcFile.importIt() except Exception as e: sResult = confirmDialog(title='SORRY !', message=toStr(e), button=["Continue", "Abort"], defaultButton="Continue", cancelButton="Abort", dismissString="Abort", icon="critical") if sResult == "Abort": break else: continue else: drcFileList[0].importIt() finally: proj.mayaLoadReferences = True
def pathRename(sSrcPath, sDstPath): try: os.rename(sSrcPath, sDstPath) except WindowsError as e: if hostApp() == "maya": raise WindowsError(toUnicode("code {} - {}: {}".format(e.args[0], e.strerror , sSrcPath))) else: raise WindowsError(e.args[0], "{}: {}".format(e.strerror , sSrcPath))
def buildMenu(self): if not self.beforeBuildingMenu(): return if hostApp() == "maya": self.beginMenu() self.populateMenu() self.endMenu() self.afterBuildingMenu()
def setProject(self, *args, **kwargs): try: return self.browserWidget.setProject(*args, **kwargs) except Exception, err: confirmDialog(title='SORRY !' , message=toStr(err) , button=["OK"] , defaultButton="OK" , cancelButton="OK" , dismissString="OK" , icon="critical") if not hostApp(): os.environ["PYTHONINSPECT"] = "1" self.close() raise
def doPublish(self, *itemList): item = itemList[-1] pubEntry = item._metaobj proj = self.model()._metamodel if isinstance(pubEntry, DrcFile): sAbsPath = pubEntry.absPath() if proj.isEditableResource(sAbsPath): if hostApp() == "maya": sExt = osp.splitext(sAbsPath)[-1] if sExt in (".ma", ".mb"): raise AssertionError("Please, publish from integrated 'Davos' menu.") self.__publishEdited(pubEntry) else: self.__publishRegular(pubEntry) else: self.__publishFiles(pubEntry)
def __new__(cls, sProjName, **kwargs): logMsg(cls.__name__ , log='all') sProjName = sProjName.lower() bExists = True proj = cls._instancesDct.get(sProjName) if not proj: bExists = False proj = object.__new__(cls) proj.name = sProjName libClass = DrcLibrary if "maya" in hostApp(): try: from davos_maya.core.mrclibrary import MrcLibrary except ImportError: pass else: libClass = MrcLibrary proj.__libClass = libClass#kwargs.pop("libraryType", DrcLibrary) proj.reset() if not kwargs.pop("empty", False): if not proj.init(**kwargs): return None proj.loadLibraries() if not bExists: cls._instancesDct[sProjName] = proj #print id(proj), proj return proj
def iterAllowedActions(self, prptyItem): sTypeName = type(prptyItem._metaobj).__name__ sCurApp = hostApp() for actionDct in self.createdActionConfigs: qAction = actionDct["action"] if qAction is None: continue sAppList = actionDct.get("apps") if sAppList and (sCurApp not in sAppList): continue fnc = actionDct["fnc"] sTargetTypeList = getattr(fnc, "act_on_types", None) if not sTargetTypeList: yield qAction else: for sPatrn in sTargetTypeList: if fnmatch(sTypeName, sPatrn): yield qAction break
def importFiles(self, *itemList): if not hostApp(): raise AssertionError("You can only import from inside another application.") drcFileList = tuple(item._metaobj for item in itemList) if len(drcFileList) > 1: for drcFile in drcFileList: try: drcFile.importIt() except Exception, e: sResult = confirmDialog(title='SORRY !', message=toStr(e), button=["Continue", "Abort"], defaultButton="Continue", cancelButton="Abort", dismissString="Abort", icon="critical") if sResult == "Abort": return else: continue