Automatic cleanup of old timers. Add user setting for how many days to keep them.
authorMike Looijmans <milo-software@users.sourceforge.net>
Fri, 1 Jan 2010 12:01:30 +0000 (13:01 +0100)
committerMike Looijmans <milo-software@users.sourceforge.net>
Fri, 1 Jan 2010 12:01:57 +0000 (13:01 +0100)
RecordTimer.py
data/setup.xml
lib/python/Components/RecordingConfig.py
timer.py

index c0d0611..6644131 100644 (file)
@@ -471,8 +471,9 @@ class RecordTimer(timer.Timer):
                                w.state = RecordTimerEntry.StateWaiting
                                self.addTimerEntry(w)
                        else:
+                               # Remove old timers as set in config
+                               self.cleanupDaily(config.recording.keep_timers.value)
                                insort(self.processed_timers, w)
-               
                self.stateChanged(w)
 
        def isRecording(self):
index a5c6118..3bcb343 100644 (file)
@@ -83,6 +83,7 @@
                        <item level="2" text="Use non-smooth winding at speeds above">config.seek.stepwise_minspeed</item>
                        <item level="2" text="Frame repeat count during non-smooth winding">config.seek.stepwise_repeat</item>
                        <item level="2" text="Limited character set for recording filenames">config.recording.ascii_filenames</item>
+                       <item level="2" text="Keep old timers for how many days">config.recording.keep_timers</item>
                </setup>        
                <setup key="harddisk" title="Harddisk setup" >
                        <item level="0" text="Harddisk standby after">config.usage.hdd_standby</item>
index ddceb7f..ad8d5eb 100644 (file)
@@ -8,3 +8,4 @@ def InitRecordingConfig():
        config.recording.margin_after = ConfigNumber(default=5)
        config.recording.debug = ConfigYesNo(default = False)
        config.recording.ascii_filenames = ConfigYesNo(default = False)
+       config.recording.keep_timers = ConfigNumber(default=7)
index 68f3d37..ff386a4 100644 (file)
--- a/timer.py
+++ b/timer.py
@@ -146,6 +146,10 @@ class Timer:
        def cleanup(self):
                self.processed_timers = [entry for entry in self.processed_timers if entry.disabled]
        
+       def cleanupDaily(self, days):
+               limit = time() - (days * 3600 * 24) 
+               self.processed_timers = [entry for entry in self.processed_timers if entry.disabled or (entry.end and (entry.end > limit))]
+
        def addTimerEntry(self, entry, noRecalc=0):
                entry.processRepeated()