[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 c

Subject: RE: Comments on the diagram(was:RE:[Pyatcron-devel-list]Cronbackend: a correction)
Date: Thu, 20 Nov 2003 17:20:14 +0100

There is an option to the crontab command that let you edit the config file of a particular user, when you're root of course. So I would prefer use this way instead of opening directly files. I've found that the crontab software does not only edit the crontab files, but also change the MTIME of the /var/spool/cron folder, which makes the Cron daemon knows that some changes have been done.
So, if software is used as normal user:
entries = commands.getoutput('crontab -l').split('\n')[3:]
If used as root:
entries = commands.getoutput('crontab -u <username> -l').split('\n')[3:]
The goal now is to build the list of users on the system.
Another thing, I do not like your option of skipping the first three lines, what if I manually edit the crontab files? Or if a new crontab software release write two lines of comments instead of three?
No, this is a really bad a way to skip comment lines. Do it as we do it everywhere:
for each $line in <file> {
     remove trailing spaces from $line
     check if first character of $line = '#'
     if not
         do stuff with $line
         skip file
end for
-----Message d'origine-----
De : address@hidden [mailto:address@hiddenDe la part de Brian Dee
Envoyé : mercredi, 19. novembre 2003 19:28
À : pyatcron-devel
Objet : RE: Comments on the diagram(was:RE:[Pyatcron-devel-list]Cronbackend: a correction)

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 ???
This e-mail contains proprietary information some or all of which may be legally privileged. It is intended for the recipient only. If an addressing or a transmission error has misdirected this e-mail, please notify the author by replying to the e-mail. If you are not the intended recipient you must not use, disclose, distribute, copy, print, or rely on this e-mail.
We take reasonable precautions to ensure our e-mails are virus free. However, we cannot accept responsibility for any virus transmitted by us and recommend that you subject any incoming e-mail to your own virus checking procedures.

reply via email to

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