Hi,

scheduler.py has a function weekdaytask. It needs five parameters as stated in the scheduler.py. weekdays and timeonday I figured out. You tell me what is name and action, args=None, kw=None ?

BRgds,

kNish
=====================================================
class WeekdayTask(DayTaskRescheduler, Task):
"""A task that is called at specific days in a week (1-7), at a fixed time on the day."""
def __init__(self, name, weekdays, timeonday, action, args=None, kw=None):
if type(timeonday) not in (list,tuple) or len(timeonday) != 2:
raise TypeError("timeonday must be a 2-tuple (hour,minute)")
if type(weekdays) not in (list,tuple):
raise TypeError("weekdays must be a sequence of weekday numbers 1-7 (1 is Monday)")
DayTaskRescheduler.__init__(self, timeonday)
Task.__init__(self, name, action, args, kw)
self.days=weekdays

def execute(self):
# This is called every day, at the correct time. We only need to
# check if we should run this task today (this day of the week).
weekday=time.localtime().tm_wday+1
if weekday in self.days:
self.action(*self.args, **self.kw)
========================================================

I don't have that module, but it looks like action is a function that is called; name would probably be a string name for the display; args would be a tuple of args to supply to the action, and kw would be a dictionary of keyword arguments to supply.

So if I had

myMondayChore(time, num_kids=2, day_care = False)

then I would create a scheduling object like this:

mytask = WeekdayTask("Monday", myMondayChore, 3, num_kids=2, day_care=False)

The three will be packed into *args; the num_kids=2 and day_care=False will be packed into **kw.

Hope that helps,
Jeff

This article has been dead for over six months. Start a new discussion instead.