[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Comments on the diagram (was:RE:[Pyatcron-devel-list]Cronbackend: a

From: Brian Dee
Subject: RE: Comments on the diagram (was:RE:[Pyatcron-devel-list]Cronbackend: a correction)
Date: Wed, 19 Nov 2003 11:28:19 -0700

On Wed, 2003-11-19 at 01:10, NICOLOVICI Xavier wrote:
About the getCommand of the CronEntry and AtEntry class. I think that they must be renamed to getRegisterString.
This function should return a string used to register the task. For the CronEntry, the getRegisterString will return:
"* * * * * /the/command/to/run -its -parameters"

This first fileds will be build with the Schedule fields and the command to run will be build with the GenericTask pointed by the Schedule object.
Does this makes things a bit clear to you?

Okay, I'll work on those things. So, according to what you've just said and the class diagrams, I should make what I had has into, and a file that inherits from and gets the RegisterString that way. And then do something similar with Right?

Now, I'm currently thinking about a CronEntryCollector and an AtEntryCollector who will be in charge of parsing the existing cron and at entries (ie retrieve the definitions from system), manage list of CronEntry and AtEntry (addition and deletion of some), export those list to a GtkList, and rebuild the system cron and at entries.
The process flow will then be as follow:
1. Create CronEntryCollector
2. CronEntryCollector.parseUserCrontab(<username>)

Normally, we would only include the crontab of the user running pyatcron, right? Do we want to implement something where if root runs pyatcron, he/she could view all of the other user's crontabs as well? If so, we would need two ways of doing it. First, since /var/spool/cron is only readable by root, to get the crontab of the user running the program, we would do something like this:

import commands

entries = commands.getoutput('crontab -l').split('\n')[3:]

This brings in each cron entry into a list ( the [3:] makes sure we don't get those first three lines that are just comments about the crontab, etc.) Then, we can just parse through it, making it more "human readable" so that the tasklist will display when the job(s) run.

If it's root running it, and we want him/her to view all users crontabs, we would have to parse the actual files in /var/spool/cron for each user:

cronfile = file('/var/spool/cron/<user>', 'r')
entries = cronfile.readlines()[3:]

I was playing around with this last night (as you can tell) trying to figure out whether to make each entry its own object, or just leave them as lists. What do you all think?
Also, as I don't know as much about GTK, how would we output the entries into the tasklist ListStore in ???

reply via email to

[Prev in Thread] Current Thread [Next in Thread]