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 stop and start, and maintain a set of current events.

Instance Methods [hide private]
 
__init__(self) source code
 
addEvent(self, start, end, content, recur=None, now=None)
Add a new event to the scheduler.
source code
 
removeEvent(self, event)
Remove an event from the scheduler.
source code
 
getCurrentEvents(self) source code
 
addEvents(self, events)
Add a new list of events to the schedule.
source code
 
replaceEvents(self, events)
Replace the set of events in the scheduler.
source code
 
subscribe(self, eventStarted, eventStopped)
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
 
_eventStopped(self, event) source code
 
_reschedule(self) source code

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

Class Variables [hide private]

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

Method Details [hide private]

addEvent(self, start, end, content, recur=None, now=None)

source code 

Add a new event to the scheduler.

Parameters:
  • start (datetime) - wall-clock time of event start
  • end (datetime) - wall-clock time of event end
  • content (str) - content of this event
  • recur (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 stops.

removeEvent(self, event)

source code 

Remove an event from the scheduler.

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

addEvents(self, events)

source code 

Add a new list of events to the schedule.

Parameters:
  • events (a new set of events) - the new events

replaceEvents(self, events)

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 stopped/start notifications.

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

subscribe(self, eventStarted, eventStopped)

source code 

Subscribe to event happenings in the scheduler.

Parameters:
  • eventStarted (Event -> None) - Function that will be called when an event starts.
  • eventStopped (Event -> None) - Function that will be called when an event stops.
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()