git.cweiske.de
/
enigma2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
remove unneeded code
[enigma2.git]
/
timer.py
diff --git
a/timer.py
b/timer.py
index c03eb1e78d3fae37087230733ff138cf03377f51..424dde0934d668e557f00313f9ee81feb708fda8 100644
(file)
--- a/
timer.py
+++ b/
timer.py
@@
-50,7
+50,7
@@
class TimerEntry:
print time.strftime("%c", time.localtime(self.begin))
print time.strftime("%c", time.localtime(self.end))
print str(time.localtime(self.begin).tm_wday)
print time.strftime("%c", time.localtime(self.begin))
print time.strftime("%c", time.localtime(self.end))
print str(time.localtime(self.begin).tm_wday)
- while ((day[time.localtime(self.begin).tm_wday] != 0) or ((day[time.localtime(self.begin).tm_wday] == 0) and self.
end
< now)):
+ while ((day[time.localtime(self.begin).tm_wday] != 0) or ((day[time.localtime(self.begin).tm_wday] == 0) and self.
begin
< now)):
print time.strftime("%c", time.localtime(self.begin))
print time.strftime("%c", time.localtime(self.end))
self.begin += 86400
print time.strftime("%c", time.localtime(self.begin))
print time.strftime("%c", time.localtime(self.end))
self.begin += 86400
@@
-81,11
+81,19
@@
class TimerEntry:
# set begin to now.
if self.begin > self.end:
self.begin = self.end
# set begin to now.
if self.begin > self.end:
self.begin = self.end
+
+ self.cancelled = True
# must be overridden!
def getNextActivation():
pass
# must be overridden!
def getNextActivation():
pass
+ def disable(self):
+ self.disabled = True
+
+ def enable(self):
+ self.disabled = False
+
class Timer:
# the time between "polls". We do this because
# we want to account for time jumps etc.
class Timer:
# the time between "polls". We do this because
# we want to account for time jumps etc.
@@
-113,6
+121,11
@@
class Timer:
for f in self.on_state_change:
f(entry)
for f in self.on_state_change:
f(entry)
+ def getNextRecordingTime(self):
+ if len(self.timer_list) > 0:
+ return self.timer_list[0].begin
+ return -1
+
def cleanup(self):
self.processed_timers = [entry for entry in self.processed_timers if entry.disabled]
def cleanup(self):
self.processed_timers = [entry for entry in self.processed_timers if entry.disabled]
@@
-124,6
+137,9
@@
class Timer:
# right into the processedTimers.
if entry.shouldSkip() or entry.state == TimerEntry.StateEnded or (entry.state == TimerEntry.StateWaiting and entry.disabled):
print "already passed, skipping"
# right into the processedTimers.
if entry.shouldSkip() or entry.state == TimerEntry.StateEnded or (entry.state == TimerEntry.StateWaiting and entry.disabled):
print "already passed, skipping"
+ print "shouldSkip:", entry.shouldSkip()
+ print "state == ended", entry.state == TimerEntry.StateEnded
+ print "waiting && disabled:", (entry.state == TimerEntry.StateWaiting and entry.disabled)
bisect.insort(self.processed_timers, entry)
entry.state = TimerEntry.StateEnded
else:
bisect.insort(self.processed_timers, entry)
entry.state = TimerEntry.StateEnded
else:
@@
-162,9
+178,16
@@
class Timer:
self.setNextActivation(min)
def timeChanged(self, timer):
self.setNextActivation(min)
def timeChanged(self, timer):
+ print "time changed"
timer.timeChanged()
timer.timeChanged()
- self.timer_list.remove(timer)
+ if timer.state == TimerEntry.StateEnded:
+ self.processed_timers.remove(timer)
+ else:
+ self.timer_list.remove(timer)
+ # give the timer a chance to re-enqueue
+ if timer.state == TimerEntry.StateEnded:
+ timer.state = TimerEntry.StateWaiting
self.addTimerEntry(timer)
def doActivate(self, w):
self.addTimerEntry(timer)
def doActivate(self, w):
@@
-173,8
+196,7
@@
class Timer:
# when activating a timer which has already passed,
# simply abort the timer. don't run trough all the stages.
if w.shouldSkip():
# when activating a timer which has already passed,
# simply abort the timer. don't run trough all the stages.
if w.shouldSkip():
- w.abort()
- bisect.insort(self.processed_timers, w)
+ w.state = TimerEntry.StateEnded
else:
# when active returns true, this means "accepted".
# otherwise, the current state is kept.
else:
# when active returns true, this means "accepted".
# otherwise, the current state is kept.