Fixed some spurious bugs.

This commit is contained in:
Griatch 2012-02-29 21:58:08 +01:00
parent 7e146eae11
commit 7818ca077a
2 changed files with 11 additions and 9 deletions

View file

@ -250,14 +250,16 @@ class StateLightSourceOn(Script):
prematurely, this hook will store the current
burntime.
"""
# calculate remaining burntime
try:
time_burnt = time.time() - self.db.script_started
except TypeError:
# can happen if script_started is not defined
time_burnt = self.interval
burntime = self.interval - time_burnt
self.obj.db.burntime = burntime
# calculate remaining burntime, if object is not
# already deleted (because it burned out)
if self.obj:
try:
time_burnt = time.time() - self.db.script_started
except TypeError:
# can happen if script_started is not defined
time_burnt = self.interval
burntime = self.interval - time_burnt
self.obj.db.burntime = burntime
def is_valid(self):
"This script is only valid as long as the lightsource burns."