def load(self, path): path = os.path.realpath(path) self._initPath( path ) self._affirmDirectories() os.chdir( path ) sys.path.insert( 0, self.envLibPath ) sys.path.insert( 0, self.getBinaryPath( 'python' ) ) #for python extension modules self.info = jsonHelper.tryLoadJSON( self.getBasePath( _GII_INFO_FILE ) ) self.config = jsonHelper.tryLoadJSON( self.getConfigPath( _GII_CONFIG_FILE ) ) if not self.config: self.config = {} jsonHelper.trySaveJSON( self.config, self.getConfigPath( _GII_CONFIG_FILE ) ) if not self.info: self.info = { 'name' : 'name', 'version' : [0,0,1], } jsonHelper.trySaveJSON( self.info, self.getBasePath( _GII_INFO_FILE ) ) self.cacheManager.load( _GII_ENV_CONFIG_DIR, self.envConfigPath ) self.assetLibrary.load( _GII_ASSET_DIR, self.assetPath, self.path, self.envConfigPath ) #will trigger other module signals.emitNow( 'project.preload', self ) signals.emitNow( 'project.load', self ) logging.info( 'project loaded: %s' % path ) return True
def save(self): signals.emitNow('project.presave', self) if self.getBasePath(): jsonHelper.trySaveJSON( self.info, self.getBasePath( _PROJECT_INFO_FILE ) ) #save asset & cache self.assetLibrary.save() self.cacheManager.clearFreeCacheFiles() self.cacheManager.save() signals.emitNow( 'project.save', self ) return True
def save(self): signals.emitNow('project.presave', self) if self.getBasePath(): jsonHelper.trySaveJSON(self.info, self.getBasePath(_PROJECT_INFO_FILE)) #save asset & cache self.assetLibrary.save() self.cacheManager.clearFreeCacheFiles() self.cacheManager.save() signals.emitNow('project.save', self) return True
def save( self ): logging.info( 'saving current project' ) signals.emitNow('project.presave', self) #save project info & config jsonHelper.trySaveJSON( self.info, self.getBasePath( _GII_INFO_FILE ), 'project info' ) #save asset & cache self.assetLibrary.save() self.cacheManager.clearFreeCacheFiles() self.cacheManager.save() signals.emitNow( 'project.save', self ) #post save logging.info( 'project saved' ) return True
def save(self): logging.info('saving current project') signals.emitNow('project.presave', self) #save project info & config jsonHelper.trySaveJSON(self.info, self.getBasePath(_GII_INFO_FILE), 'project info') #save asset & cache self.assetLibrary.save() self.cacheManager.clearFreeCacheFiles() self.cacheManager.save() signals.emitNow('project.save', self) #post save logging.info('project saved') return True
def load(self, path): path = os.path.realpath(path) self._initPath(path) self._affirmDirectories() os.chdir(path) sys.path.insert(0, self.envLibPath) sys.path.insert( 0, self.getBinaryPath('python')) #for python extension modules self.info = jsonHelper.tryLoadJSON(self.getBasePath(_GII_INFO_FILE)) self.config = jsonHelper.tryLoadJSON( self.getConfigPath(_GII_CONFIG_FILE)) if not self.config: self.config = {} jsonHelper.trySaveJSON(self.config, self.getConfigPath(_GII_CONFIG_FILE)) if not self.info: self.info = { 'name': 'name', 'version': [0, 0, 1], } jsonHelper.trySaveJSON(self.info, self.getBasePath(_GII_INFO_FILE)) self.cacheManager.load(_GII_ENV_CONFIG_DIR, self.envConfigPath) self.assetLibrary.load(_GII_ASSET_DIR, self.assetPath, self.path, self.envConfigPath) #will trigger other module signals.emitNow('project.preload', self) signals.emitNow('project.load', self) logging.info('project loaded: %s' % path) return True
def saveAssetTable( self, **option ): outputPath = option.get( 'path', self.assetIndexPath ) deployContext = option.get( 'deploy_context', False ) mapping = deployContext and deployContext.fileMapping table={} for path, node in self.assetTable.items(): item={} table[ path ]=item #common item['type'] = node.getType() item['groupType'] = node.getGroupType() item['filePath'] = node.getFilePath() or False item['tags'] = node.getTags() #oebjectfiles if mapping: mapped = {} for key, path in node.objectFiles.items(): mapped[ key ] = mapping.get( path, path ) item['objectFiles'] = mapped else: item['objectFiles'] = node.objectFiles item['dependency'] = node.dependency item['fileTime'] = node.getFileTime() #non deploy information if not deployContext: item['manager'] = node.managerName item['deploy'] = node.deployState item['cacheFiles'] = node.cacheFiles item['properties'] = node.properties item['modifyState'] = node.modifyState #mark cache files for name, cacheFile in node.cacheFiles.items(): CacheManager.get().touchCacheFile( cacheFile ) node.saveMetaDataTable() if not jsonHelper.trySaveJSON( table, outputPath, 'asset index' ): return False logging.info( 'asset table saved' ) return True
def saveAssetTable(self, **option): outputPath = option.get('path', self.assetIndexPath) deployContext = option.get('deploy_context', False) mapping = deployContext and deployContext.fileMapping table = {} for path, node in self.assetTable.items(): item = {} table[path] = item #common item['type'] = node.getType() item['groupType'] = node.getGroupType() item['filePath'] = node.getFilePath() or False item['tags'] = node.getTags() #oebjectfiles if mapping: mapped = {} for key, path in node.objectFiles.items(): mapped[key] = mapping.get(path, path) item['objectFiles'] = mapped else: item['objectFiles'] = node.objectFiles item['dependency'] = node.dependency item['fileTime'] = node.getFileTime() #non deploy information if not deployContext: item['manager'] = node.managerName item['deploy'] = node.deployState item['cacheFiles'] = node.cacheFiles item['properties'] = node.properties item['modifyState'] = node.modifyState #mark cache files for name, cacheFile in node.cacheFiles.items(): CacheManager.get().touchCacheFile(cacheFile) node.saveMetaDataTable() if not jsonHelper.trySaveJSON(table, outputPath, 'asset index'): return False logging.info('asset table saved') return True
def saveConfig(self): if self.getBasePath(): jsonHelper.trySaveJSON( self.config, self.getBasePath(_PROJECT_EDITOR_DIR + '/' + _PROJECT_CONFIG_FILE))
def save(self): #save cache index jsonHelper.trySaveJSON(self.cacheFileTable, self.cacheIndexPath, 'cache index')
def save( self ): #save cache index jsonHelper.trySaveJSON( self.cacheFileTable, self.cacheIndexPath, 'cache index' )
def saveConfig(self): jsonHelper.trySaveJSON(self.config, self.getPath(_GII_APP_CONFIG_FILE), 'project config')
def saveConfig( self ): if self.getBasePath(): jsonHelper.trySaveJSON( self.config, self.getBasePath( _PROJECT_EDITOR_DIR + '/' + _PROJECT_CONFIG_FILE ))
def saveConfig( self ): jsonHelper.trySaveJSON( self.config, self.getPath( _GII_APP_CONFIG_FILE ), 'project config' )