import abc

import six
import eventlet

__all__ = [
    'Sensor',
    'PollingSensor'
]


@six.add_metaclass(abc.ABCMeta)
class BaseSensor(object):
    """
    Base Sensor class - not to be instantiated directly.
    """

    def __init__(self, sensor_service, config=None):
        self._sensor_service = sensor_service
        self._config = config or {}

    @abc.abstractmethod
    def setup(self):
        """
        Run the sensor initialization / setup code (if any).
        """
        pass

    @abc.abstractmethod
    def run(self):
        """
        Run the sensor.
        """
        pass

    @abc.abstractmethod
    def cleanup(self):
        """
        Run the sensor cleanup code (if any).
        """
        pass

    @abc.abstractmethod
    def add_trigger(self, trigger):
        """
        """
        pass

    @abc.abstractmethod
    def update_trigger(self, trigger):
        """
        """
        pass

    @abc.abstractmethod
    def remove_trigger(self, trigger):
        """
        """
        pass


class Sensor(BaseSensor):
    """
    Base class to be inherited from by the passive sensors.
    """

    @abc.abstractmethod
    def run(self):
        pass


class PollingSensor(BaseSensor):
    """
    Base class to be inherited from by the active sensors.

    Active sensors are the ones which periodically polling a 3rd party system
    for new information.
    """

    def __init__(self, sensor_service, config, poll_interval=5):
        super(PollingSensor, self).__init__(sensor_service=sensor_service, config=config)
        self._poll_interval = poll_interval

    def run(self):
        while True:
            self.poll()
            eventlet.sleep(self._poll_interval)

    @abc.abstractmethod
    def poll(self):
        """
        Poll 3rd party system for new information.
        """
        pass

@@ -1610,120 +1610,8 @@
 al%0A%0A
-    def run(self):%0A        while True:%0A            self.poll()%0A            eventlet.sleep(self._poll_interval)%0A%0A
     
@@ -1718,28 +1718,580 @@
 n.%0A        %22%22%22%0A        pass%0A
+%0A    def run(self):%0A        while True:%0A            self.poll()%0A            eventlet.sleep(self._poll_interval)%0A%0A    def get_poll_interval(self):%0A        %22%22%22%0A        Retrieve current poll interval.%0A%0A        :return: Current poll interval.%0A        :rtype: %60%60float%60%60%0A        %22%22%22%0A        return self._poll_interval%0A%0A    def set_poll_interval(self, poll_interval):%0A        %22%22%22%0A        Set the poll interval.%0A%0A        :param poll_interval: Poll interval to use.%0A        :type poll_interval: %60%60float%60%60%0A        %22%22%22%0A        self._poll_interval = poll_interval%0A

Add set_poll_interval and get_poll_interval methods to the base PollingSensor class.