prevent log from crashing if timeout occurs on delta

master
agp8x 2015-09-29 19:21:28 +02:00
parent bdc9700043
commit 4878b49af6
1 changed files with 6 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import os
from timeFunctions import * from timeFunctions import *
from config import SensorType, setup_data_echo, setup_data_log from config import SensorType, setup_data_echo, setup_data_log
from config import settings from config import settings
from tinkerforge import ip_connection
class Logger(object): class Logger(object):
@ -63,7 +64,11 @@ class Logger(object):
self.dataecho.info(sensor + ': ' + str(value / unit[1]) + ' ' + unit[2]) self.dataecho.info(sensor + ': ' + str(value / unit[1]) + ' ' + unit[2])
def cb_delta(self, value, name, type, getter): def cb_delta(self, value, name, type, getter):
try:
delta = value - getter() delta = value - getter()
except ip_connection.Error as e:
self.log.error(e)
return
self.log.debug("DELTA of %s and %s is: %s (base was: %s)", name, getter, delta, value) self.log.debug("DELTA of %s and %s is: %s (base was: %s)", name, getter, delta, value)
self.cb_generic(delta, name, type) self.cb_generic(delta, name, type)