From: Felix Domke Date: Wed, 16 Nov 2005 11:15:24 +0000 (+0000) Subject: timer: fix displayed state. Don't save instant records. properly remove timerentries. X-Git-Tag: 2.6.0~5131 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/63fd3a60724b9c03a70ce847955f2aa9facb423f timer: fix displayed state. Don't save instant records. properly remove timerentries. --- diff --git a/RecordTimer.py b/RecordTimer.py index cf49df23..aa48415a 100644 --- a/RecordTimer.py +++ b/RecordTimer.py @@ -25,6 +25,7 @@ class RecordTimerEntry(timer.TimerEntry): else: self.epg_data = "" + self.dontSave = False self.description = description self.timer = None self.record_service = None @@ -101,7 +102,6 @@ class RecordTimer(timer.Timer): print "unable to load timers from file!" def loadTimer(self): - # TODO: PATH! doc = xml.dom.minidom.parse(self.Filename) @@ -116,6 +116,10 @@ class RecordTimer(timer.Timer): 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') @@ -127,9 +131,10 @@ class RecordTimer(timer.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): @@ -143,12 +148,13 @@ class RecordTimer(timer.Timer): 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() diff --git a/lib/python/Components/TimerList.py b/lib/python/Components/TimerList.py index 078210bd..43a55fde 100644 --- a/lib/python/Components/TimerList.py +++ b/lib/python/Components/TimerList.py @@ -4,7 +4,7 @@ from GUIComponent import * from Tools.FuzzyDate import FuzzyTime from enigma import eListboxPythonMultiContent, eListbox, gFont - +from timer import TimerEntry RT_HALIGN_LEFT = 0 RT_HALIGN_RIGHT = 1 @@ -20,20 +20,31 @@ RT_WRAP = 32 # # | | -# | | +# | | # 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 = "" 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): diff --git a/lib/python/Screens/InfoBarGenerics.py b/lib/python/Screens/InfoBarGenerics.py index 1ef39982..3af52ae8 100644 --- a/lib/python/Screens/InfoBarGenerics.py +++ b/lib/python/Screens/InfoBarGenerics.py @@ -362,6 +362,7 @@ class InfoBarInstantRecord: # 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: diff --git a/timer.py b/timer.py index 1679a9b7..a230545d 100644 --- a/timer.py +++ b/timer.py @@ -52,15 +52,17 @@ class Timer: 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) @@ -72,7 +74,15 @@ class Timer: 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 @@ -86,7 +96,7 @@ class Timer: 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)