コード例 #1
0
ファイル: ResourceCollector.py プロジェクト: sernst/PyGlass
    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
コード例 #2
0
ファイル: WidgetUiCompiler.py プロジェクト: hannahp/PyGlass
    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()
コード例 #3
0
ファイル: PyGlassApplication.py プロジェクト: sernst/PyGlass
    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
コード例 #4
0
ファイル: ResourceCollector.py プロジェクト: hannahp/PyGlass
    def run(self):
        """Doc..."""
        resources = self._compiler.resources

        #-------------------------------------------------------------------------------------------
        # APP 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 == 'local':
                    resources.append(item)

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

        #-------------------------------------------------------------------------------------------
        # 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]
            )

        #-------------------------------------------------------------------------------------------
        # 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
コード例 #5
0
ファイル: AlembicUtils.py プロジェクト: hannahp/PyGlass
    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
コード例 #6
0
ファイル: PyGlassModelUtils.py プロジェクト: sernst/PyGlass
    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
コード例 #7
0
ファイル: PyGlassApplication.py プロジェクト: sernst/PyGlass
    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')
コード例 #8
0
    def _getIconPath(self):
        path = self.iconPath
        if not path:
            return ''

        if isinstance(path, basestring):
            if os.path.isabs(path) and os.path.exists(path):
                return FileUtils.cleanupPath(path)
            else:
                path = path.replace('\\', '/').strip('/').split('/')

        path.append('icons' if OsUtils.isWindows() else 'icons.iconset')
        out = PyGlassEnvironment.getRootResourcePath(*path, isDir=True)
        if os.path.exists(out):
            return out
        return ''
コード例 #9
0
ファイル: PyGlassModelUtils.py プロジェクト: sernst/PyGlass
    def getMigrationPathFromDatabaseUrl(cls, databaseUrl, root=False, resourcesPath=None):
        urlParts = databaseUrl.split("://")
        if urlParts[0].lower() == "shared":
            path = ["shared", "alembic"]
        else:
            path = ["apps", urlParts[0], "alembic"]

        if not root:
            path += urlParts[-1].split("/")

            # Remove the extension
            if path[-1].endswith(".vdb"):
                path[-1] = path[-1][:-4]

        if resourcesPath:
            return FileUtils.makeFolderPath(resourcesPath, *path, isDir=True)

        return PyGlassEnvironment.getRootResourcePath(*path, isDir=True)
コード例 #10
0
ファイル: AlembicUtils.py プロジェクト: sernst/PyGlass
    def hasMigrationEnvironment(cls, databaseUrl, resourcesPath =None):
        """ Determines whether or not the specified application database currently has a migration
            environment setup
            :param databaseUrl:
            :param resourcesPath:
            :return: True or false depending on the presence of a migration environment """

        if not resourcesPath:
            resourcesPath = PyGlassEnvironment.getRootResourcePath(isDir=True)

        migrationPath = PyGlassModelUtils.getMigrationPathFromDatabaseUrl(
            databaseUrl=databaseUrl, resourcesPath=resourcesPath)

        if not os.path.exists(migrationPath):
            return False
        if not os.path.exists(FileUtils.makeFilePath(migrationPath, 'alembic.ini')):
            return False
        if not os.path.exists(FileUtils.makeFolderPath(migrationPath, 'versions')):
            return False
        return True
コード例 #11
0
 def _runPreMainWindowImpl(self):
     # Overrides the resource path for running StaticFlow applications within the PyGlass app
     StaticFlowEnvironment.setResourceRootPath(PyGlassEnvironment.getRootResourcePath())
コード例 #12
0
ファイル: PyGlassWindow.py プロジェクト: sernst/PyGlass
 def getRootResourcePath(self, *args, **kwargs):
     return PyGlassEnvironment.getRootResourcePath(*args, **kwargs)
コード例 #13
0
ファイル: PyGlassWindow.py プロジェクト: sernst/PyGlass
 def rootResourcePath(self):
     return PyGlassEnvironment.getRootResourcePath()
コード例 #14
0
ファイル: PyGlassApplication.py プロジェクト: sernst/PyGlass
 def getAppResourcePath(self, *args, **kwargs):
     return PyGlassEnvironment.getRootResourcePath('apps', self.appID, *args, **kwargs)
コード例 #15
0
ファイル: CadenceEnvironment.py プロジェクト: sernst/Cadence
 def getAppResourcePath(cls, *args, **kwargs):
     """getAppResourcePath doc..."""
     return PyGlassEnvironment.getRootResourcePath(
         'apps', cls.APP_ID, *args, **kwargs)
コード例 #16
0
ファイル: PyGlassApplication.py プロジェクト: hannahp/PyGlass
                sys.stdout = open(logPath + 'out.log', 'w')

                try:
                    sys.stderr.close()
                except Exception, err:
                    pass
                sys.stderr = open(logPath + 'error.log', 'w')
        except Exception, err:
            raise

        self._qApplication = QtGui.QApplication(appArgs if appArgs else [])

        if self.splashScreenUrl:
            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')

        self._runPreMainWindowImpl()

        windowClass = self.mainWindowClass
        assert inspect.isclass(windowClass)

        self._window = windowClass(