[Checkins] SVN: lovely.remotetask/branches/gotcha-z3c-taskqueue/src/lovely/remotetask/ make browser/README.txt tests pass again

Godefroid Chapelle gotcha at bubblenet.be
Thu Apr 22 06:37:11 EDT 2010


Log message for revision 111256:
  make browser/README.txt tests pass again
  

Changed:
  U   lovely.remotetask/branches/gotcha-z3c-taskqueue/src/lovely/remotetask/browser/README.txt
  U   lovely.remotetask/branches/gotcha-z3c-taskqueue/src/lovely/remotetask/job.py

-=-
Modified: lovely.remotetask/branches/gotcha-z3c-taskqueue/src/lovely/remotetask/browser/README.txt
===================================================================
--- lovely.remotetask/branches/gotcha-z3c-taskqueue/src/lovely/remotetask/browser/README.txt	2010-04-22 10:36:11 UTC (rev 111255)
+++ lovely.remotetask/branches/gotcha-z3c-taskqueue/src/lovely/remotetask/browser/README.txt	2010-04-22 10:37:11 UTC (rev 111256)
@@ -19,6 +19,7 @@
 Now let's have a look at the job's table:
 
   >>> browser.getLink('tasks').click()
+  >>> browser.getLink('Jobs').click()
 
 You can see the available tasks:
 
@@ -150,7 +151,7 @@
 We modify the python logger to get the log output.
 
   >>> import logging
-  >>> logger = logging.getLogger("lovely.remotetask")
+  >>> logger = logging.getLogger("z3c.taskqueue")
   >>> logger.setLevel(logging.ERROR)
   >>> import StringIO
   >>> io = StringIO.StringIO()
@@ -183,7 +184,7 @@
 
   >>> import threading
   >>> for thread in threading.enumerate():
-  ...     if thread.getName().startswith('remotetasks.'):
+  ...     if thread.getName().startswith('taskqueue.'):
   ...         print thread.isDaemon()
   True
 

Modified: lovely.remotetask/branches/gotcha-z3c-taskqueue/src/lovely/remotetask/job.py
===================================================================
--- lovely.remotetask/branches/gotcha-z3c-taskqueue/src/lovely/remotetask/job.py	2010-04-22 10:36:11 UTC (rev 111255)
+++ lovely.remotetask/branches/gotcha-z3c-taskqueue/src/lovely/remotetask/job.py	2010-04-22 10:37:11 UTC (rev 111256)
@@ -11,137 +11,4 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""Task Service Implementation
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-import time
-import datetime
-import persistent
-
-import zope.interface
-
-from zope.schema.fieldproperty import FieldProperty
-
-from lovely.remotetask import interfaces
-
-
-class Job(persistent.Persistent):
-    """A simple, non-persistent task implementation."""
-    zope.interface.implements(interfaces.IJob)
-
-    id = FieldProperty(interfaces.IJob['id'])
-    task = FieldProperty(interfaces.IJob['task'])
-    status = FieldProperty(interfaces.IJob['status'])
-    input = FieldProperty(interfaces.IJob['input'])
-    output = FieldProperty(interfaces.IJob['output'])
-    error = FieldProperty(interfaces.IJob['error'])
-    created = FieldProperty(interfaces.IJob['created'])
-    started = FieldProperty(interfaces.IJob['started'])
-    completed = FieldProperty(interfaces.IJob['completed'])
-
-    def __init__(self, id, task, input):
-        self.id = id
-        self.task = task
-        self.input = input
-        self.created = datetime.datetime.now()
-
-    def __repr__(self):
-        return '<%s %r>' %(self.__class__.__name__, self.id)
-
-
-class CronJob(Job):
-    """A job for reocuring tasks"""
-    zope.interface.implements(interfaces.ICronJob)
-
-    minute = FieldProperty(interfaces.ICronJob['minute'])
-    hour = FieldProperty(interfaces.ICronJob['hour'])
-    dayOfMonth = FieldProperty(interfaces.ICronJob['dayOfMonth'])
-    month = FieldProperty(interfaces.ICronJob['month'])
-    dayOfWeek = FieldProperty(interfaces.ICronJob['dayOfWeek'])
-    scheduledFor = FieldProperty(interfaces.ICronJob['scheduledFor'])
-
-    def __init__(self, id, task, input,
-                 minute=(),
-                 hour=(),
-                 dayOfMonth=(),
-                 month=(),
-                 dayOfWeek=(),
-                 delay=None,
-                ):
-        super(CronJob, self).__init__(id, task, input)
-        self.update(minute, hour, dayOfMonth, month, dayOfWeek, delay)
-
-    def update(self,
-               minute=(),
-               hour=(),
-               dayOfMonth=(),
-               month=(),
-               dayOfWeek=(),
-               delay=None,
-               ):
-        self.minute = minute
-        self.hour = hour
-        self.dayOfMonth = dayOfMonth
-        self.month = month
-        self.dayOfWeek = dayOfWeek
-        if delay == 0:
-            delay = None
-        self.delay = delay
-
-    def timeOfNextCall(self, now=None):
-        if now is None:
-            now = int(time.time())
-        next = now
-        if self.delay is not None:
-            next += self.delay
-            return int(next)
-        inc = lambda t: 60
-        lnow = list(time.gmtime(now)[:5])
-        if self.minute:
-            pass
-        elif self.hour:
-            inc = lambda t: 60*60
-            lnow = lnow[:4]
-        elif self.dayOfMonth:
-            inc = lambda t: 24*60*60
-            lnow = lnow[:3]
-        elif self.dayOfWeek:
-            inc = lambda t: 24*60*60
-            lnow = lnow[:3]
-        elif self.month:
-            mlen = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
-            def minc(t):
-                m = time.gmtime(t)[1] - 1
-                if m == 1:
-                    # see if we have a leap year
-                    y = time.gmtime(t)[0]
-                    if y % 4 != 0:
-                        d = 28
-                    elif y % 400 == 0:
-                        d = 29
-                    elif y % 100 == 0:
-                        d = 28
-                    else:
-                        d = 29
-                    return d*24*60*60
-                return mlen[m]*24*60*60
-            inc = minc
-            lnow = lnow[:3]
-            lnow[2] = 1
-        while len(lnow)<9:
-            lnow.append(0)
-        while next <= now+365*24*60*60:
-            next += inc(next)
-            fields = time.gmtime(next)
-            if ((self.month and fields[1] not in self.month) or
-                (self.dayOfMonth and fields[2] not in self.dayOfMonth) or
-                (self.dayOfWeek and fields[6] % 7 not in self.dayOfWeek) or
-                (self.hour and fields[3] not in self.hour) or
-                (self.minute and fields[4] not in self.minute)):
-                continue
-            return int(next)
-        return None
-
+from z3c.taskqueue.job import *



More information about the checkins mailing list