本文整理汇总了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
示例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)
示例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()
示例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
示例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()
示例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
示例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
示例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
示例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]
示例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
示例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
示例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
示例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
示例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
示例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')