use workaround for magic-ci
[enigma2.git] / RecordTimer.py
index 58bf676..c3b948d 100644 (file)
@@ -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
@@ -38,9 +39,9 @@ class RecordTimerEntry(timer.TimerEntry):
                else:
                        description = ""
                
-               print begin_date
-               print service_name
-               print description
+               print "begin_date: " + str(begin_date)
+               print "service_name: " + str(service_name)
+               print "description: " + str(description)
                self.Filename = Directories.getRecordingFilename(service_name)
                #begin_date + " - " + service_name + description)
                
@@ -85,9 +86,12 @@ def createTimer(xml):
        end = int(xml.getAttribute("end"))
        serviceref = ServiceReference(str(xml.getAttribute("serviceref")))
        description = xml.getAttribute("description")
+       repeated = xml.getAttribute("repeated")
        epgdata = xml.getAttribute("epgdata")
        #filename = xml.getAttribute("filename")
-       return RecordTimerEntry(begin, end, serviceref, epgdata, description)
+       entry = RecordTimerEntry(begin, end, serviceref, epgdata, description)
+       entry.repeated = int(repeated)
+       return entry
 
 class RecordTimer(timer.Timer):
        def __init__(self):
@@ -101,7 +105,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,20 +119,26 @@ 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')
                        t.setAttribute("begin", str(timer.begin))
                        t.setAttribute("end", str(timer.end))
                        t.setAttribute("serviceref", str(timer.service_ref))
+                       t.setAttribute("repeated", str(timer.repeated))                 
                        #t.setAttribute("epgdata", timer.)
                        t.setAttribute("description", timer.description)
                        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 +152,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()