def get_environment(self,id, *args, **kwargs): if not id in self._environments.keys(): raise EnvironmentNotFound() else: #raise EnvironmentNotFound() #defer.succeed(self._environments[id]) return self._environments[id]
def delete_environment(self, environment): """Delete an environment object .""" if hasattr(environment, "_dbId"): yield self.delete(environment._dbId) delattr(environment, "_dbId") else: raise EnvironmentNotFound()
def save_environment(self, environment=None, *args, **kwargs): if self._path_manager is None: raise EnvironmentNotFound( "Path manager not set, cannot delete environment files") environmentPath = os.path.join(self._path_manager.dataPath, environment.name) if not os.path.exists(environmentPath): os.makedirs(environmentPath) yield self._daoManager.save_environment(environment, *args, **kwargs)
def save_environments(self, lEnvironment): if self._path_manager is None: raise EnvironmentNotFound( "Path manager not set, cannot delete environment files") for environment in lEnvironment: environmentPath = os.path.join(self._path_manager.dataPath, environment.name) if not os.path.exists(environmentPath): os.makedirs(environmentPath) yield self._daoManager.save_environments(lEnvironment)
def delete_environments(self, lEnvironment): if self._path_manager is None: raise EnvironmentNotFound( "Path manager not set, cannot delete environment files") for environment in lEnvironment: yield self._daoManager.delete_environment(environment) environmentPath = os.path.join(self._path_manager.dataPath, environment.name) if os.path.exists(environmentPath) and os.path.isdir( environmentPath): shutil.rmtree(environmentPath)
def delete_environment(self, environment=None): #TODO: improve path handing if self._path_manager is None: raise EnvironmentNotFound( "Path manager not set, cannot delete environment files") yield self._daoManager.delete_environment(environment) environmentPath = os.path.join(self._path_manager.dataPath, environment.name) if os.path.exists(environmentPath) and os.path.isdir(environmentPath): shutil.rmtree(environmentPath)
def load_environment(self, id=None, *args, **kwargs): """Retrieve data from environment object.""" rows = yield self.select(id=str(id)) result = None if len(rows) > 0: id, name, description, status = rows[0] result = Environment(name=name, description=description, status=status) result.cid = uuid.UUID(id) else: raise EnvironmentNotFound() defer.returnValue(result)
def get_environment(self, envId): env = self.environments.get(envId) if env is None: raise EnvironmentNotFound() return env