Author: dmeyer
Date: Thu Oct 25 15:59:13 2007
New Revision: 2881

Log:
simpler version of AtTimer and OneShotAtTimer

Modified:
   trunk/base/src/notifier/attimer.py

Modified: trunk/base/src/notifier/attimer.py
==============================================================================
--- trunk/base/src/notifier/attimer.py  (original)
+++ trunk/base/src/notifier/attimer.py  Thu Oct 25 15:59:13 2007
@@ -1,36 +1,34 @@
 import time
 from timer import OneShotTimer
 
-class AtTimer(OneShotTimer):
+class OneShotAtTimer(OneShotTimer):
 
     def schedule(self, hour=range(24), min=range(60), sec=0):
         if not isinstance(hour, (list, tuple)):
             hour = [ hour ]
-        self._hour = 3, hour
         if not isinstance(min, (list, tuple)):
             min = [ min ]
-        self._min = 4, min
         if not isinstance(sec, (list, tuple)):
             sec = [ sec ]
-        self._sec = 5, sec
-        self.start()
+        self._timings = [ ( 5, sec), (4, min), (3, hour) ]
+        self._schedule_next()
 
 
-    def __call__(self, *args, **kwargs):
-        super(AtTimer,self).__call__(*args, **kwargs)
-        self.start()
-
-        
-    def _getnext(self):
+    def _schedule_next(self):
         ctime = time.time()
         next = list(time.localtime(ctime))
-        for pos, values in ( self._sec, self._min, self._hour ):
+        for pos, values in self._timings:
             for v in values:
                 if v > next[pos]:
                     next[pos] = v
-                    return time.mktime(next) - ctime
+                    self.start(time.mktime(next) - ctime)
+                    return
             next[pos] = values[0]
-        return time.mktime(next + 24 * 60 * 60) - ctime
-        
-    def start(self):
-        super(AtTimer,self).start(self._getnext())
+        self.start(time.mktime(next + 24 * 60 * 60) - ctime)
+
+
+class AtTimer(OneShotAtTimer):
+    
+    def __call__(self, *args, **kwargs):
+        super(AtTimer,self).__call__(*args, **kwargs)
+        self._schedule_next()

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to