errcron.cronjob module

class errcron.cronjob.CronJob

Bases: object

Job runner for errcron, handling job running trigger and action

do_action(plugin, do_time)

Run cronjob action with plugin

Parameters:
  • plugin (errbot.BotPlugin) – running Errbot plugin
  • do_time (datetime.datetime) – action triggered time
Returns:

Returned value from action

is_runnable(time)

Check whether job run action at specified time

Parameters:time (datetime.datetime) – Time to run action
Returns:Job is runnable or not
Return type:boolean
set_action(action, *args)

Set action and arguments to run in triggered time

Parameters:
  • action (str) – function path as anction
  • args (list or tuple) – function arguments
set_crontab(crontab)
set_triggers(trigger_format, trigger_time)

Set trigger_format and trigger_time (recommend)

Parameters:
  • trigger_format (basestring) – datetime format used by strftime
  • trigger_format – datetime values returned by strftime
Raises:

ValueError

errcron.cronjob.load_from_string(crontab, format='crontab')

Load cronjob from single string

Parameters:
  • crontab (str) – crontab string(trigger_format, trigger_time, function, args)
  • format (str) – job trigger type
Returns:

Cronjob

Return type:

errcron.cronjob.CronJob

errcron.cronjob.parse_crontab(crontab)