Esempio n. 1
0
 def setUp(self):
     self._path_manager = PathManager()
     self._path_manager.dataPath = "."
     self._persistenceLayer = PersistenceLayer(
         pathManager=self._path_manager)
     self.deviceManager = DeviceManager(self._persistenceLayer)
     #yield self._persistenceLayer.setup()
     yield self.deviceManagers.setup()
Esempio n. 2
0
 def __init__(self,parent = None, persistenceLayer= None, name="home",description="Add Description here",status="active",*args,**kwargs):
     BaseComponent.__init__(self, parent)
     self._persistenceLayer = persistenceLayer
     self.name=name
     self.description=description
     self.status=status
     self._devices=DeviceManager(self)
     self._tasks=TaskManager(self)
Esempio n. 3
0
class Test_device_manager(unittest.TestCase):
    @defer.inlineCallbacks
    def setUp(self):
        self._path_manager = PathManager()
        self._path_manager.dataPath = "."
        self._persistenceLayer = PersistenceLayer(
            pathManager=self._path_manager)
        self.deviceManager = DeviceManager(self._persistenceLayer)
        #yield self._persistenceLayer.setup()
        yield self.deviceManagers.setup()

    def tearDown(self):
        self.deviceManager.teardown()
        self._persistenceLayer.tearDown()
        if os.path.exists("pollapli.db"):
            os.remove("pollapli.db")
Esempio n. 4
0
 def setUp(self):
     self._path_manager = PathManager()
     self._path_manager.dataPath = "."
     self._persistenceLayer = PersistenceLayer(pathManager = self._path_manager)
     self.deviceManager=DeviceManager(self._persistenceLayer)
     #yield self._persistenceLayer.setup()
     yield self.deviceManagers.setup()
Esempio n. 5
0
class Test_device_manager(unittest.TestCase):
    
    @defer.inlineCallbacks
    def setUp(self):
        self._path_manager = PathManager()
        self._path_manager.dataPath = "."
        self._persistenceLayer = PersistenceLayer(pathManager = self._path_manager)
        self.deviceManager=DeviceManager(self._persistenceLayer)
        #yield self._persistenceLayer.setup()
        yield self.deviceManagers.setup()
        
    def tearDown(self):
        self.deviceManager.teardown()
        self._persistenceLayer.tearDown()
        if os.path.exists("pollapli.db"):
            os.remove("pollapli.db")
Esempio n. 6
0
 def __init__(
     self,
     parent=None,
     persistenceLayer=None,
     name="home",
     description="Add Description here",
     status="active",
     *args,
     **kwargs
 ):
     BaseComponent.__init__(self, parent)
     self._persistenceLayer = persistenceLayer
     self.name = name
     self.description = description
     self.status = status
     self._devices = DeviceManager(self)
     self._tasks = TaskManager(self)
Esempio n. 7
0
class Environment(BaseComponent):
    def __init__(self,parent = None, persistenceLayer= None, name="home",description="Add Description here",status="active",*args,**kwargs):
        BaseComponent.__init__(self, parent)
        self._persistenceLayer = persistenceLayer
        self.name=name
        self.description=description
        self.status=status
        self._devices=DeviceManager(self)
        self._tasks=TaskManager(self)
        
    def __eq__(self, other):
        return self.cid == other.cid and self.name == other.name and self.description == other.description and self.status == other.status
    
    def __ne__(self, other):
        return not self.__eq__(other)
    
    def __str__(self):
        return "%s %s %s" %(self.name,self.description,self.status)
    
    def __getattr__(self, attr_name):
        if hasattr(self._devices, attr_name):
            return getattr(self._devices, attr_name)
        elif hasattr(self._tasks, attr_name):
            return getattr(self._tasks, attr_name)
        else:
            raise AttributeError(attr_name)
    """
    ####################################################################################
    Configuration and shutdown methods
    """
    @defer.inlineCallbacks
    def setup(self):
        """
        Method configuring additional elements of the current environment
        """
        yield self._devices.setup()
        yield self._tasks.setup()
        log.msg("Environment ",self.name ,"with id", self.cid," setup correctly", logLevel=logging.CRITICAL, system="environment")

    def teardown(self):
        """
Esempio n. 8
0
class Environment(BaseComponent):
    def __init__(
        self,
        parent=None,
        persistenceLayer=None,
        name="home",
        description="Add Description here",
        status="active",
        *args,
        **kwargs
    ):
        BaseComponent.__init__(self, parent)
        self._persistenceLayer = persistenceLayer
        self.name = name
        self.description = description
        self.status = status
        self._devices = DeviceManager(self)
        self._tasks = TaskManager(self)

    def __eq__(self, other):
        return (
            self.cid == other.cid
            and self.name == other.name
            and self.description == other.description
            and self.status == other.status
        )

    def __ne__(self, other):
        return not self.__eq__(other)

    def __str__(self):
        return "%s %s %s" % (self.name, self.description, self.status)

    def __getattr__(self, attr_name):
        if hasattr(self._devices, attr_name):
            return getattr(self._devices, attr_name)
        elif hasattr(self._tasks, attr_name):
            return getattr(self._tasks, attr_name)
        else:
            raise AttributeError(attr_name)

    """
    ####################################################################################
    Configuration and shutdown methods
    """

    @defer.inlineCallbacks
    def setup(self):
        """
        Method configuring additional elements of the current environment
        """
        yield self._devices.setup()
        yield self._tasks.setup()
        log.msg(
            "Environment ",
            self.name,
            "with id",
            self.cid,
            " setup correctly",
            logLevel=logging.CRITICAL,
            system="environment",
        )

    def teardown(self):
        """