else:
self.epg_data = ""
+ self.dontSave = False
self.description = description
self.timer = None
self.record_service = None
print "unable to load timers from file!"
def loadTimer(self):
-
# TODO: PATH!
doc = xml.dom.minidom.parse(self.Filename)
root_element.appendChild(doc.createTextNode("\n"))
for timer in self.timer_list + self.processed_timers:
+ # some timers (instant records) don't want to be saved.
+ # skip them
+ if timer.dontSave:
+ continue
t = doc.createTextNode("\t")
root_element.appendChild(t)
t = doc.createElement('timer')
root_element.appendChild(t)
t = doc.createTextNode("\n")
root_element.appendChild(t)
-
+
file = open(self.Filename, "w")
doc.writexml(codecs.getwriter('UTF-8')(file))
+ file.write("\n")
file.close()
def record(self, entry):
elif entry.state != timer.TimerEntry.StateEnded:
entry.activate(timer.TimerEntry.EventAbort)
self.timer_list.remove(entry)
+ self.calcNextActivation()
print "timer did not yet start - removing"
else:
print "timer did already end - doing nothing."
-
- self.calcNextActivation()
-
+
+ # now the timer should be in the processed_timers list. remove it from there.
+ self.processed_timers.remove(entry)
def shutdown(self):
self.saveTimer()
from Tools.FuzzyDate import FuzzyTime
from enigma import eListboxPythonMultiContent, eListbox, gFont
-
+from timer import TimerEntry
RT_HALIGN_LEFT = 0
RT_HALIGN_RIGHT = 1
#
# | <Service> <Name of the Timer> |
-# | <start> <end> |
+# | <start, end> <state> |
#
def TimerEntryComponent(timer, processed):
res = [ timer ]
res.append((0, 0, 400, 30, 0, RT_HALIGN_LEFT, timer.service_ref.getServiceName()))
- res.append((0, 30, 200, 20, 1, RT_HALIGN_LEFT, "%s, %s" % FuzzyTime(timer.begin)))
+ res.append((0, 30, 200, 20, 1, RT_HALIGN_LEFT, "%s, %s ... %s" % (FuzzyTime(timer.begin) + FuzzyTime(timer.end)[1:])))
- res.append((300, 0, 200, 20, 1, RT_HALIGN_RIGHT, timer.description))
- if processed:
- res.append((300, 30, 200, 20, 1, RT_HALIGN_RIGHT, FuzzyTime(timer.end)[1]))
+ res.append((300, 0, 200, 20, 1, RT_HALIGN_RIGHT, timer.description))
+
+ if not processed:
+ if timer.state == TimerEntry.StateWait:
+ state = "waiting"
+ elif timer.state == TimerEntry.StatePrepare:
+ state = "about to start"
+ elif timer.state == TimerEntry.StateRunning:
+ state = "recording..."
+ else:
+ state = "<unknown>"
else:
- res.append((300, 30, 200, 20, 1, RT_HALIGN_RIGHT, "done"))
+ state = "done!"
+
+ res.append((300, 30, 200, 20, 1, RT_HALIGN_RIGHT, state))
+
return res
class TimerList(HTMLComponent, GUIComponent):
# fix me, description.
self.recording = self.session.nav.recordWithTimer(time.time(), time.time() + 3600, serviceref, epg, "instant record")
+ self.recording.dontSave = True
def recordQuestionCallback(self, answer):
if answer == False:
self.timer = eTimer()
self.timer.timeout.get().append(self.calcNextActivation)
+ self.lastActivation = time.time()
self.calcNextActivation()
- def addTimerEntry(self, entry):
+ def addTimerEntry(self, entry, noRecalc=0):
# we either go trough Prepare/Start/End-state if the timer is still running,
# or skip it when it's alrady past the end.
if entry.end > time.time():
bisect.insort(self.timer_list, entry)
- self.calcNextActivation()
+ if not noRecalc:
+ self.calcNextActivation()
else:
bisect.insort(self.processed_timers, entry)
self.next = when
def calcNextActivation(self):
+ if self.lastActivation > time.time():
+ print "[timer.py] timewarp - re-evaluating all processed timers."
+ tl = self.processed_timers
+ self.processed_timers = [ ]
+ for x in tl:
+ self.addTimerEntry(x, noRecalc=1)
+
self.processActivation()
+ self.lastActivation = time.time()
min = int(time.time()) + self.MaxWaitTime
def timeChanged(self, timer):
self.timer_list.remove(timer)
- bisect.insort(self.timer_list, timer)
+ self.addTimerEntry(timer)
def doActivate(self, w):
w.activate(w.state)