當前位置: 首頁>>代碼示例>>Python>>正文


Python PyGlassEnvironment.PyGlassEnvironment類代碼示例

本文整理匯總了Python中pyglass.app.PyGlassEnvironment.PyGlassEnvironment的典型用法代碼示例。如果您正苦於以下問題:Python PyGlassEnvironment類的具體用法?Python PyGlassEnvironment怎麽用?Python PyGlassEnvironment使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了PyGlassEnvironment類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _deployResources

    def _deployResources(cls):
        """ On windows the resource folder data is stored within the application install directory.
            However, due to permissions issues, certain file types cannot be accessed from that
            directory without causing the program to crash. Therefore, the stored resources must
            be expanded into the user's AppData/Local folder. The method checks the currently
            deployed resources folder and deploys the stored resources if the existing resources
            either don't exist or don't match the currently installed version of the program. """

        if not OsUtils.isWindows() or not PyGlassEnvironment.isDeployed:
            return False

        storagePath       = PyGlassEnvironment.getInstallationPath('resource_storage', isDir=True)
        storageStampPath  = FileUtils.makeFilePath(storagePath, 'install.stamp')
        resourcePath      = PyGlassEnvironment.getRootResourcePath(isDir=True)
        resourceStampPath = FileUtils.makeFilePath(resourcePath, 'install.stamp')

        try:
            resousrceData = JSON.fromFile(resourceStampPath)
            storageData   = JSON.fromFile(storageStampPath)
            if resousrceData['CTS'] == storageData['CTS']:
                return False
        except Exception as err:
            pass

        SystemUtils.remove(resourcePath)
        FileUtils.mergeCopy(storagePath, resourcePath)
        return True
開發者ID:sernst,項目名稱:PyGlass,代碼行數:27,代碼來源:PyGlassApplication.py

示例2: __init__

    def __init__(self):
        """Creates a new instance of PyGlassApplication."""
        QtCore.QObject.__init__(self)
        self._qApplication = None
        self._window       = None
        self._splashScreen = None

        # Sets a temporary standard out and error for deployed applications in a write allowed
        # location to prevent failed write results.
        if PyGlassEnvironment.isDeployed:
            if appdirs:
                userDir = appdirs.user_data_dir(self.appID, self.appGroupID)
            else:
                userDir = FileUtils.createPath(
                    os.path.expanduser('~'), '.pyglass', self.appGroupID, self.appID, isDir=True)

            path = FileUtils.createPath(
                userDir,
                self.appID + '_out.log', isFile=True)
            folder = FileUtils.getDirectoryOf(path, createIfMissing=True)
            sys.stdout = open(path, 'w+')

            FileUtils.createPath(
                appdirs.user_data_dir(self.appID, self.appGroupID),
                self.appID + '_error.log',
                isFile=True)
            folder = FileUtils.getDirectoryOf(path, createIfMissing=True)
            sys.stderr = open(path, 'w+')

        PyGlassEnvironment.initializeAppSettings(self)
開發者ID:hannahp,項目名稱:PyGlass,代碼行數:30,代碼來源:PyGlassApplication.py

示例3: __init__

    def __init__(self, *args, **kwargs):
        """Creates a new instance of PyGlassApplication."""
        QtCore.QObject.__init__(self)
        self._qApplication      = None
        self._window            = None
        self._splashScreen      = None

        self.redirectLogOutputs()
        PyGlassEnvironment.initializeAppSettings(self)
        self.redirectLogOutputs()
開發者ID:sernst,項目名稱:PyGlass,代碼行數:10,代碼來源:PyGlassApplication.py

示例4: upgradeDatabase

    def upgradeDatabase(cls, databaseUrl):
        """upgradeDatabase doc..."""
        from pyglass.alembic.AlembicUtils import AlembicUtils

        if not AlembicUtils.hasAlembic:
            return False

        AlembicUtils.upgradeDatabase(
            databaseUrl=databaseUrl,
            resourcesPath=PyGlassEnvironment.getRootResourcePath(isDir=True),
            localResourcesPath=PyGlassEnvironment.getRootLocalResourcePath(isDir=True),
        )
        return True
開發者ID:sernst,項目名稱:PyGlass,代碼行數:13,代碼來源:PyGlassModelUtils.py

示例5: __init__

    def __init__(self, rootPath =None, recursive =True, **kwargs):
        """Creates a new instance of WidgetUiCompiler."""
        self._log        = Logger(self)
        self._verbose    = ArgsUtils.get('verbose', False, kwargs)
        self._recursive  = recursive
        self._pythonPath = os.path.normpath(sys.exec_prefix)

        if rootPath and os.path.isabs(rootPath):
            self._rootPath = FileUtils.cleanupPath(rootPath, isDir=True)
        elif rootPath:
            parts = rootPath.split(os.sep if rootPath.find(os.sep) != -1 else '/')
            self._rootPath = PyGlassEnvironment.getRootResourcePath(*parts, isDir=True)
        else:
            self._rootPath = PyGlassEnvironment.getRootResourcePath()
開發者ID:hannahp,項目名稱:PyGlass,代碼行數:14,代碼來源:WidgetUiCompiler.py

示例6: _createSetupFile

    def _createSetupFile(self, binPath):
        path = FileUtils.createPath(binPath, 'setup.py', isFile=True)
        scriptPath = inspect.getabsfile(self.applicationClass)

        try:
            sourcePath = PyGlassEnvironment.getPyGlassResourcePath(
                '..', 'setupSource.txt', isFile=True)
            f      = open(sourcePath, 'r+')
            source = f.read()
            f.close()
        except Exception as err:
            print(err)
            return None

        try:
            f = open(path, 'w+')
            f.write(source.replace(
                '##SCRIPT_PATH##', StringUtils.escapeBackSlashes(scriptPath)
            ).replace(
                '##RESOURCES##', StringUtils.escapeBackSlashes(JSON.asString(self.resources))
            ).replace(
                '##INCLUDES##', StringUtils.escapeBackSlashes(JSON.asString(self.siteLibraries))
            ).replace(
                '##ICON_PATH##', StringUtils.escapeBackSlashes(self._createIcon(binPath))
            ).replace(
                '##APP_NAME##', self.appDisplayName
            ).replace(
                '##SAFE_APP_NAME##', self.appDisplayName.replace(' ', '_') ))
            f.close()
        except Exception as err:
            print(err)
            return None

        return path
開發者ID:sernst,項目名稱:PyGlass,代碼行數:34,代碼來源:PyGlassApplicationCompiler.py

示例7: _createNsisInstallerScript

    def _createNsisInstallerScript(self, binPath):
        path = FileUtils.createPath(binPath, 'installer.nsi', isFile=True)

        try:
            sourcePath = PyGlassEnvironment.getPyGlassResourcePath(
                '..', 'installer.tmpl.nsi', isFile=True)
            f = open(sourcePath, 'r+')
            source = f.read()
            f.close()
        except Exception as err:
            print(err)
            return None

        try:
            f = open(path, 'w+')
            f.write(source.replace(
                '##APP_NAME##', self.appDisplayName
            ).replace(
                '##APP_ID##', self.application.appID
            ).replace(
                '##APP_GROUP_ID##', self.application.appGroupID
            ).replace(
                '##SAFE_APP_NAME##', self.appDisplayName.replace(' ', '_') ))
            f.close()
        except Exception as err:
            print(err)
            return None

        return path
開發者ID:sernst,項目名稱:PyGlass,代碼行數:29,代碼來源:PyGlassApplicationCompiler.py

示例8: _changeDirToLocalAppPath

 def _changeDirToLocalAppPath(cls, localResourcesPath):
     """_changeDirToLocalAppPath doc..."""
     if not localResourcesPath:
         localResourcesPath = PyGlassEnvironment.getRootLocalResourcePath(isDir=True)
     lastDir = os.path.abspath(os.curdir)
     os.chdir(localResourcesPath)
     return lastDir
開發者ID:sernst,項目名稱:PyGlass,代碼行數:7,代碼來源:AlembicUtils.py

示例9: _getIconSheet

 def _getIconSheet(self):
     key = str(self._sizeIndex) + '-' + str(self._isDark)
     if key not in self._ICON_SHEETS:
         self._ICON_SHEETS[key] = QtGui.QPixmap(PyGlassEnvironment.getPyGlassResourcePath(
             'icons-%s-%s.png' % (
                 'dark' if self._isDark else 'light', str(self._ICON_SIZES[self._sizeIndex])
         ), isFile=True))
     return self._ICON_SHEETS[key]
開發者ID:hannahp,項目名稱:PyGlass,代碼行數:8,代碼來源:IconElement.py

示例10: run

    def run(self):
        """Doc..."""
        resources = self._compiler.resources

        #-------------------------------------------------------------------------------------------
        # RESOURCES
        #       If no resource folders were specified copy the entire contents of the resources
        #       folder. Make sure to skip the local resources path in the process.
        if not resources:
            for item in os.listdir(PyGlassEnvironment.getRootResourcePath(isDir=True)):
                itemPath = PyGlassEnvironment.getRootResourcePath(item)
                if os.path.isdir(itemPath) and not item in ['local', 'apps']:
                    resources.append(item)

        for container in resources:
            parts = container.replace('\\', '/').split('/')
            self._copyResourceFolder(
                PyGlassEnvironment.getRootResourcePath(*parts, isDir=True), parts)

        #-------------------------------------------------------------------------------------------
        # APP RESOURCES
        appResources = self._compiler.resourceAppIds
        if not appResources:
            appResources = []
        for appResource in appResources:
            itemPath = PyGlassEnvironment.getRootResourcePath('apps', appResource, isDir=True)
            if not os.path.exists(itemPath):
                self._log.write('[WARNING]: No such app resource path found: %s' % appResource)
                continue
            self._copyResourceFolder(itemPath, ['apps', appResource])

        #-------------------------------------------------------------------------------------------
        # PYGLASS RESOURCES
        #       Copy the resources from the PyGlass
        resources = []
        for item in os.listdir(PyGlassEnvironment.getPyGlassResourcePath('..', isDir=True)):
            itemPath = PyGlassEnvironment.getPyGlassResourcePath('..', item)
            if os.path.isdir(itemPath):
                resources.append(item)

        for container in resources:
            self._copyResourceFolder(
                PyGlassEnvironment.getPyGlassResourcePath('..', container), [container])

        # Create a stamp file in resources for comparing on future installations
        creationStampFile = FileUtils.makeFilePath(self._targetPath, 'install.stamp')
        JSON.toFile(creationStampFile, {'CTS':TimeUtils.toZuluPreciseTimestamp()})

        #-------------------------------------------------------------------------------------------
        # CLEANUP
        if self._verbose:
            self._log.write('CLEANUP: Removing unwanted destination files.')
        self._cleanupFiles(self._targetPath)

        self._copyPythonStaticResources()

        if self._verbose:
            self._log.write('COMPLETE: Resource Collection')

        return True
開發者ID:sernst,項目名稱:PyGlass,代碼行數:60,代碼來源:ResourceCollector.py

示例11: getAnalysisSettings

def getAnalysisSettings():
    """ Retrieves the analysis configuration settings file as a SettingsConfig
        instance that can be modified and saved as needed.
        @return: SettingsConfig """
    if not __LOCALS__.SETTINGS_CONFIG:
        __LOCALS__.SETTINGS_CONFIG = SettingsConfig(
            FileUtils.makeFilePath(
                PyGlassEnvironment.getRootLocalResourcePath(
                    'analysis', isDir=True),
                'analysis.json'), pretty=True)
    return __LOCALS__.SETTINGS_CONFIG
開發者ID:sernst,項目名稱:Cadence,代碼行數:11,代碼來源:DataLoadUtils.py

示例12: getAppDatabaseItems

    def getAppDatabaseItems(cls, appName):
        databaseRoot = PyGlassEnvironment.getRootResourcePath('apps', appName, 'data')
        if not os.path.exists(databaseRoot):
            return []

        results = []
        os.path.walk(databaseRoot, cls._findAppDatabases, {
            'root':databaseRoot,
            'results':results,
            'appName':appName
        })
        return results
開發者ID:hannahp,項目名稱:PyGlass,代碼行數:12,代碼來源:AlembicUtils.py

示例13: _createNsisInstallerScript

    def _createNsisInstallerScript(self, binPath):
        path = FileUtils.createPath(binPath, 'installer.nsi', isFile=True)

        try:
            sourcePath = PyGlassEnvironment.getPyGlassResourcePath(
                '..', 'installer.tmpl.nsi', isFile=True)
            f = open(sourcePath, 'r+')
            source = f.read()
            f.close()
        except Exception, err:
            print err
            return None
開發者ID:hannahp,項目名稱:PyGlass,代碼行數:12,代碼來源:PyGlassApplicationCompiler.py

示例14: _createSetupFile

    def _createSetupFile(self, binPath):
        path = FileUtils.createPath(binPath, 'setup.py', isFile=True)
        scriptPath = inspect.getabsfile(self.applicationClass)

        try:
            sourcePath = PyGlassEnvironment.getPyGlassResourcePath(
                '..', 'setupSource.txt', isFile=True)
            f      = open(sourcePath, 'r+')
            source = f.read()
            f.close()
        except Exception, err:
            print err
            return None
開發者ID:hannahp,項目名稱:PyGlass,代碼行數:13,代碼來源:PyGlassApplicationCompiler.py

示例15: _showSplashScreen

    def _showSplashScreen(self):
        """_showSplashScreen doc..."""
        parts = str(self.splashScreenUrl).split(':', 1)
        if len(parts) == 1 or parts[0].lower == 'app':
            splashImagePath = PyGlassEnvironment.getRootResourcePath(
                'apps', self.appID, parts[-1], isFile=True)
        else:
            splashImagePath = None

        if splashImagePath and os.path.exists(splashImagePath):
            splash = QtGui.QSplashScreen(QtGui.QPixmap(splashImagePath))
            splash.show()
            self._splashScreen = splash
            self.updateSplashScreen('Initializing User Interface')
開發者ID:sernst,項目名稱:PyGlass,代碼行數:14,代碼來源:PyGlassApplication.py


注:本文中的pyglass.app.PyGlassEnvironment.PyGlassEnvironment類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。