Пример #1
0
    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)
Пример #2
0
    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)
Пример #3
0
    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
Пример #4
0
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))
Пример #5
0
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))
Пример #6
0
    def buildMenu(self):

        if not self.beforeBuildingMenu():
            return

        if hostApp() == "maya":

            self.beginMenu()
            self.populateMenu()
            self.endMenu()

        self.afterBuildingMenu()
Пример #7
0
    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
Пример #8
0
    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)
Пример #9
0
    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
Пример #10
0
    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
Пример #11
0
    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
    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