Commit c838b91f authored by Florent Fourcot's avatar Florent Fourcot Committed by Romain Bignon

Add SensorNotFound exception

parent 8e6b0fba
......@@ -21,7 +21,7 @@
from __future__ import with_statement
from .browser import SachsenBrowser
from weboob.capabilities.gauge import ICapGauge, GaugeSensor, Gauge
from weboob.capabilities.gauge import ICapGauge, GaugeSensor, Gauge, SensorNotFound
from weboob.tools.backend import BaseBackend
......@@ -75,9 +75,13 @@ class SachsenLevelBackend(BaseBackend, ICapGauge):
def iter_gauge_history(self, sensor):
if not isinstance(sensor, GaugeSensor):
sensor = self._get_sensor_by_id(sensor)
if sensor is None:
raise SensorNotFound()
return self.browser.iter_history(sensor)
def get_last_measure(self, sensor):
if not isinstance(sensor, GaugeSensor):
sensor = self._get_sensor_by_id(sensor)
if sensor is None:
raise SensorNotFound()
return sensor.lastvalue
......@@ -18,10 +18,16 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from .base import IBaseCap, CapBaseObject, StringField, FloatField, DateField, Field
from .base import IBaseCap, CapBaseObject, StringField, FloatField, DateField, Field, UserError
__all__ = ['Gauge', 'GaugeSensor', 'GaugeMeasure', 'ICapGauge']
__all__ = ['Gauge', 'GaugeSensor', 'GaugeMeasure', 'ICapGauge', 'SensorNotFound']
class SensorNotFound(UserError):
"""
Not found a sensor
"""
class Gauge(CapBaseObject):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment