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