aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Domke <tmbinc@elitedvb.net>2005-11-16 11:15:24 +0000
committerFelix Domke <tmbinc@elitedvb.net>2005-11-16 11:15:24 +0000
commit63fd3a60724b9c03a70ce847955f2aa9facb423f (patch)
treedb3a1e0ecca4eeec34874063500cd6276ab6fee3
parent3ff9ec2869649c38251899fc0fbe9c651a061dfc (diff)
downloadenigma2-63fd3a60724b9c03a70ce847955f2aa9facb423f.tar.gz
enigma2-63fd3a60724b9c03a70ce847955f2aa9facb423f.zip
timer: fix displayed state. Don't save instant records. properly remove timerentries.
-rw-r--r--RecordTimer.py16
-rw-r--r--lib/python/Components/TimerList.py25
-rw-r--r--lib/python/Screens/InfoBarGenerics.py1
-rw-r--r--timer.py16
4 files changed, 43 insertions, 15 deletions
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
#
# | <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):
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)