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()
示例#3
0
 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)
示例#4
0
 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)
示例#5
0
 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)
示例#6
0
    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)
示例#8
0
 def get_environment(self, envId):
     env = self.environments.get(envId)
     if env is None:
         raise EnvironmentNotFound()
     return env