Package flumotion :: Package component :: Package base :: Module scheduler :: Class Scheduler
[hide private]

Class Scheduler

source code

extern.log.log.Loggable --+
                          |
                         Scheduler
Known Subclasses:

I keep track of upcoming events.

I can provide notifications when events end and start, and maintain a set of current events.

Instance Methods [hide private]
 
__init__(self) source code
 
_addEvent(self, event) source code
 
addEvent(self, uid, start, end, content, rrule=None, now=None, exdates=None)
Add a new event to the scheduler
source code
 
removeEvent(self, event)
Remove an event from the scheduler.
source code
 
_removeEvent(self, event) source code
Event
getCurrentEvents(self, now=None, windowSize=None)
Get a list of current events.
source code
 
addEvents(self, events)
Add a new list of events to the schedule.
source code
 
replaceEvents(self, events, now=None)
Replace the set of events in the scheduler.
source code
 
subscribe(self, eventStarted, eventEnded)
Subscribe to event happenings in the scheduler.
source code
 
unsubscribe(self, id)
Unsubscribe from event happenings in the scheduler.
source code
 
_eventStarted(self, event) source code
 
_eventEnded(self, event) source code
 
_reschedule(self) source code
 
_cancelScheduledCalls(self) source code

Inherited from extern.log.log.Loggable: __providedBy__, debug, doLog, error, info, log, logFunction, logObjectName, warning, warningFailure, writeMarker

Class Variables [hide private]
  windowSize = datetime.timedelta(1)

Inherited from extern.log.log.Loggable: __implemented__, __provides__, logCategory

Method Details [hide private]

addEvent(self, uid, start, end, content, rrule=None, now=None, exdates=None)

source code 

Add a new event to the scheduler

Parameters:
  • uid (str) - uid of event
  • start (datetime) - wall-clock time of event start
  • end (datetime) - wall-clock time of event end
  • content (str) - content of this event
  • rrule (None, str, or datetime.timedelta) - recurrence rule, either as a string parseable by datetime.rrule.rrulestr or as a datetime.timedelta
Returns:
an Event that can later be passed to removeEvent, if so desired. The event will be removed or rescheduled automatically when it ends.

removeEvent(self, event)

source code 

Remove an event from the scheduler.

Parameters:
  • event (Event) - an event, as returned from addEvent()

getCurrentEvents(self, now=None, windowSize=None)

source code 

Get a list of current events.

Parameters:
  • now (datetime) - Use now as localtime. If not set the local time is used.
  • windowSize (timedelta) - get events on this window. If not set, the returned events will be on the class windowSize member.
Returns: Event
Events that are being run.

addEvents(self, events)

source code 

Add a new list of events to the schedule.

Parameters:
  • events (list of Event) - the new events

replaceEvents(self, events, now=None)

source code 

Replace the set of events in the scheduler.

This function is different than simply removing all events then adding new ones, because it tries to avoid spurious ended/started notifications.

Parameters:
  • events (a sequence of Event) - the new events

subscribe(self, eventStarted, eventEnded)

source code 

Subscribe to event happenings in the scheduler.

Parameters:
  • eventStarted (function taking Event) - function that will be called when an event starts
  • eventEnded (function taking Event) - function that will be called when an event ends
Returns:
A subscription ID that can later be passed to unsubscribe().

unsubscribe(self, id)

source code 

Unsubscribe from event happenings in the scheduler.

Parameters:
  • id - Subscription ID received from subscribe()