littles changes

This commit is contained in:
Bastian Schroll 2018-01-14 23:21:22 +01:00
parent c2a09ad7c3
commit 3c2aa557fe
2 changed files with 16 additions and 4 deletions

View file

@ -34,7 +34,11 @@ class Packet:
self._packet = {"timestamp": time.time()}
else:
logging.debug("create bwPacket from string")
self._packet = eval(bwPacket)
try:
self._packet = eval(bwPacket.strip())
except:
# todo can we repair teh packet anyway?
logging.exception("error while create packet from string")
def __str__(self):
"""!Return the intern _packet dict as string"""

View file

@ -35,6 +35,7 @@ class Plugin:
# for time counting
self._sumTime = 0
self._cumTime = 0
self._setupTime = 0
self._alarmTime = 0
self._teardownTime = 0
@ -109,6 +110,7 @@ class Plugin:
self._teardownTime = time.time() - self._tmpTime
self._sumTime = self._setupTime + self._alarmTime + self._teardownTime
self._cumTime += self._sumTime
self._endTime = time.time()
logging.debug("[%s] took %0.3f seconds", self._pluginName, self._sumTime)
@ -120,9 +122,15 @@ class Plugin:
"""!Returns statistical information's from last plugin run
@return Statistics as pyton dict"""
stats = {"runCount": self._runCount, "sumTime": self._sumTime, "cumTime": self._runCount * self._sumTime,
"setupTime": self._setupTime, "alarmTime": self._alarmTime, "teardownTime": self._teardownTime,
"setupErrorCount": self._setupErrorCount, "alarmErrorCount": self._alarmErrorCount, "teardownErrorCount": self._teardownErrorCount}
stats = {"runCount": self._runCount,
"sumTime": self._sumTime,
"cumTime": self._cumTime,
"setupTime": self._setupTime,
"alarmTime": self._alarmTime,
"teardownTime": self._teardownTime,
"setupErrorCount": self._setupErrorCount,
"alarmErrorCount": self._alarmErrorCount,
"teardownErrorCount": self._teardownErrorCount}
return stats
def onLoad(self):