| |
- Crontab
- CrontabEntry
- CrontabEntryReader
- threading.Thread(threading._Verbose)
-
- CrontabEntriesSpy
- CrontabExecuter
- CrontabSniper
class Crontab |
|
Main Crontab class. It initialises the queues needed, launches
the two threads spying over events (CrontabEntriesSpy and
CrontabExecuter). Calling getNextEvent() on it will return the
next event of the queue. |
|
Methods defined here:
- _Crontab__addEntry = __addEntry(self, cte)
- Append cte to self.__entries
- _Crontab__delEntry = __delEntry(self, cte)
- Delete cte from self.__entries
- __init__(self, worker=None)
- getNextEvent(self)
- Retrieve next event of the public queue
- removeAll(self)
- Remove all the entries
- schedule(self, ecrontab, cmd, name)
- - cmd is the string representing the command to run
- ecrontab is a string to the ecrontab format
- name is a name given to the entry
- start(self)
- Start the Crontab. Just start the two crucial threads
- stop(self)
- Stop the crontab
Data and non-method functions defined here:
- QUEUE_SIZE_CMDS = 3
- QUEUE_SIZE_ENTRIES = 3
- SLEEP_TIME = 0.5
- __doc__ = 'Main Crontab class. It initialises the queues ne...t will return the\n next event of the queue.'
- __module__ = 'common.crontab'
|
class CrontabEntriesSpy(threading.Thread) |
|
This is a thread that spies over each entry in a crontab.
Every SLEEP_TIME seconds, it locks the entries, walks over
them, and call its spy() function to see if it is matched |
|
- Method resolution order:
- CrontabEntriesSpy
- threading.Thread
- threading._Verbose
Methods defined here:
- __init__(self, lock, entries)
- run(self)
Data and non-method functions defined here:
- SLEEP_TIME = 1
- __doc__ = 'This is a thread that spies over each entry in a...d call its spy() function to see if it is matched'
- __module__ = 'common.crontab'
Methods inherited from threading.Thread:
- _Thread__bootstrap = __bootstrap(self)
- _Thread__delete = __delete(self)
- _Thread__stop = __stop(self)
- __repr__(self)
- _set_daemon(self)
- getName(self)
- isAlive(self)
- isDaemon(self)
- join(self, timeout=None)
- setDaemon(self, daemonic)
- setName(self, name)
- start(self)
Data and non-method functions inherited from threading.Thread:
- _Thread__initialized = 0
Methods inherited from threading._Verbose:
- _note(self, format, *args)
|
class CrontabEntry |
|
Gateway between the CrontabEntryReader and the Crontab.
It uses CrontabEntryReader to parse and check the entry.
The Crontab is then able to use spy() on it to see if
there's a crontab match |
|
Methods defined here:
- _CrontabEntry__addToQueue = __addToQueue(self, tuple)
- Add tuple to the entriesQueue
- _CrontabEntry__getTime = __getTime(self)
- Returns the time as GMT
- _CrontabEntry__match = __match(self, arg, value)
- Return 1 if arg of self matches value.
There are two cases: if self.arg == value, or if
self.attr == '*'. Attr can be any of seconds, minutes,
hours, dom, month, dow
- _CrontabEntry__matchedEntry = __matchedEntry(self)
- Called when the entry was matched against the current time.
Add the event to the entriesQueue. The format is:
(time, currentEntryObject)
time is the moment the entry was matched in seconds
currentEntryObject is self
- _CrontabEntry__printTime = __printTime(self)
- Print the current time as GMT
- _CrontabEntry__star = __star(self, arg)
- Returns 1 if arg == '*', 0 otherwise
- _CrontabEntry__washStr = __washStr(self, str)
- Wash string str
- __init__(self, str, cmd, queue, name)
- spy(self)
- Looks if the entry in this object is matched by the current time
This is called every second by Crontab
Data and non-method functions defined here:
- STAR = '*'
- __doc__ = "Gateway between the CrontabEntryReader and the C...() on it to see if\n there's a crontab match"
- __module__ = 'common.crontab'
|
class CrontabEntryReader |
|
Class that defines a crontab entry.
We follow the philosophy of crontab but add the seconds field
for finer control over executions |
|
Methods defined here:
- _CrontabEntryReader__setField = __setField(self, num, field)
- Set the num field of self.entry. For example, if num == 0
it will set self.seconds to the first element of the entry
- _CrontabEntryReader__washStr = __washStr(self, str)
- Remove trailing and leading spaces of the entry
- __init__(self, str, cmd)
- Empty fields and clean the entry string
- parse(self)
- Parse the entry, set the corresponding fields and return them
as a tuple
- validate(self)
- Basic check to see if an entry is valid
Data and non-method functions defined here:
- FIELDS = ['seconds', 'minutes', 'hours', 'dom', 'month', 'dow']
- STAR = '*'
- __doc__ = 'Class that defines a crontab entry.\n We fo...ds field\n for finer control over executions'
- __module__ = 'common.crontab'
|
class CrontabExecuter(threading.Thread) |
|
Executes command for a particular crontab. It is a thread
that loops while getting events from the entriesQueue of the
crontab. When it gets a tuple, it passes the execution of the
command of the matched entry to a worker. This worker can be
passed to the constuctor. If it's not, a worker is created |
|
- Method resolution order:
- CrontabExecuter
- threading.Thread
- threading._Verbose
Methods defined here:
- _CrontabExecuter__doExec = __doExec(self, *args)
- Exec args[0] and put the result on the queue
- _CrontabExecuter__putOnQueue = __putOnQueue(self, stdout, entry, execTime, taken)
- Puts the arguments as a tuple on the queue
- __init__(self, wker, entriesQueue, cmdQueue)
- Initialises queues and worker
- run(self)
- The job of the thread. Calling stop() on the object will make
it leave, put an empty event on the queue and leave the thread
Data and non-method functions defined here:
- STOP_MESSAGE = ('GOING', 'BED')
- __doc__ = "Executes command for a particular crontab. It is... the constuctor. If it's not, a worker is created"
- __module__ = 'common.crontab'
Methods inherited from threading.Thread:
- _Thread__bootstrap = __bootstrap(self)
- _Thread__delete = __delete(self)
- _Thread__stop = __stop(self)
- __repr__(self)
- _set_daemon(self)
- getName(self)
- isAlive(self)
- isDaemon(self)
- join(self, timeout=None)
- setDaemon(self, daemonic)
- setName(self, name)
- start(self)
Data and non-method functions inherited from threading.Thread:
- _Thread__initialized = 0
Methods inherited from threading._Verbose:
- _note(self, format, *args)
|
class CrontabSniper(threading.Thread) |
|
Snipe over a specific Crontab. The classic use of this is to
create a class heritating CrontabSniper, and define a
handleEvent(self, stdout, entry, time, spent) function inside
that will be called each time an event happened on a entry of the
crontab |
|
- Method resolution order:
- CrontabSniper
- threading.Thread
- threading._Verbose
Methods defined here:
- __init__(self, crontab=None)
- handleEvent(self, stdout, entry, time, spent)
- run(self)
- Gets next crontab events and calls handleEvent
- stop(self)
- Stop the sniper
Data and non-method functions defined here:
- __doc__ = 'Snipe over a specific Crontab. The classic use o...n event happened on a entry of the\n crontab'
- __module__ = 'common.crontab'
Methods inherited from threading.Thread:
- _Thread__bootstrap = __bootstrap(self)
- _Thread__delete = __delete(self)
- _Thread__stop = __stop(self)
- __repr__(self)
- _set_daemon(self)
- getName(self)
- isAlive(self)
- isDaemon(self)
- join(self, timeout=None)
- setDaemon(self, daemonic)
- setName(self, name)
- start(self)
Data and non-method functions inherited from threading.Thread:
- _Thread__initialized = 0
Methods inherited from threading._Verbose:
- _note(self, format, *args)
| |