pyatcron-devel-list
[Top][All Lists]
Advanced

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

[Pyatcron-devel-list] GUI integration of the scheduler list


From: Julien Olivier
Subject: [Pyatcron-devel-list] GUI integration of the scheduler list
Date: Fri, 09 Apr 2004 16:53:53 +0100

Hi list !

 - First, I have removed #!/usr/bin/python2.2 from config.py, because it
is useless.
 - Then, I have changed /usr/bin/python2.2 to /usr/bin/python in
pyatcron.py for it to work on my FC2
 - Finally, I have done some changes in both scheduler.py and mainwin.py
to integrate the scheduler list into the main window automatically.

The crontab file is parsed on startup and the list widget is populated
from it.

A few comments:
 - If you changed your crontab after pyatcron has been launched, the
list is not updated. You need to restart pyatcron.
 - If the scheduler doesn't have a name, their command line is displayed
instead
 - Schedulers don't have names for now. We have to find a way to
integrate names for tasks in the crontab file.

Now I have a question about the parser. What is cron expected to do if
you enter 10-30/3 ? Does it mean 10,13,16... or does it mean 12,15,18...
? In the parser's current algorithm, the second solution is rendered,
but I have doubts that it may be correct. Do you have any idea Xavier ?
Should I test it using cron ?

Any comment/critic/question is welcome, of course.
-- 
Julien Olivier <address@hidden>
Index: config.py
===================================================================
RCS file: /cvsroot/pyatcron/pyatcron/src/config.py,v
retrieving revision 1.1
diff -r1.1 config.py
1,2d0
< #!/usr/bin/python2.2
< 
Index: pyatcron.py
===================================================================
RCS file: /cvsroot/pyatcron/pyatcron/src/pyatcron.py,v
retrieving revision 1.2
diff -r1.2 pyatcron.py
1c1
< #!/usr/bin/python2.2
---
> #!/usr/bin/python
Index: scheduler.py
===================================================================
RCS file: /cvsroot/pyatcron/pyatcron/src/lib/scheduler.py,v
retrieving revision 1.3
diff -r1.3 scheduler.py
9a10
>         self.name = ""
31a33,40
>     def getId(self):
>         return(self.id)
> 
>     def getName(self):
>         tmpName = self.name
>         if (len (tmpName) == 0):
>           tmpName = self.task.command
>         return(tmpName)
42a52
>         print "Name        : ",self.name
Index: mainwin.py
===================================================================
RCS file: /cvsroot/pyatcron/pyatcron/src/lib/mainwin.py,v
retrieving revision 1.1
diff -r1.1 mainwin.py
3a4,7
> import datetime
> import time
> 
> from lib.schedulelist import ScheduleList
18a23,25
>               # Get the list of schedulers
>               self.list = ScheduleList ()
> 
301,305c308,360
<               model.set (model.append (), 0, 2, 1, False, 2, "Save all my 
HOME folder", 3, "12/01/03 4:00 AM", 4, self.insensitiveColor)
<               model.set (model.append (), 0, 4, 1, True, 2, "Wake me up on 
the morning", 3, "Tomorrow 7:00 AM", 4, self.insensitiveColor)
<               model.set (model.append (), 0, 6, 1, False, 2, "Start 
downloading CD1", 3, "Today 9:00 PM", 4, self.insensitiveColor)
<               model.set (model.append (), 0, 8, 1, False, 2, "Start 
downloading CD2", 3, "Today 11:00 PM", 4, self.insensitiveColor)
<               model.set (model.append (), 0, 10, 1, False, 2, "Start 
downloading CD3", 3, "Tomorrow 2:00 AM", 4, self.insensitiveColor)
---
>               for entry in self.list:
> 
>                       # Determine when the task will occur next
>                       entryAttr = entry.getAttributes ();
> 
>                       baseTimeStamp = time.time ()
>                       baseTime = datetime.datetime.fromtimestamp 
> (baseTimeStamp)
>                       nextTimeStamp = -1
> 
>                       for year in [baseTime.year, baseTime.year + 1]:
>                               for month in entryAttr [3]:
>                                       for day in entryAttr [2]:
>                                               for weekday in entryAttr [4]:
>                                                       if (weekday == 0):
>                                                               weekday = 7
>                                                       weekday = weekday - 1
> 
>                                                       testTimeStamp = 
> time.mktime ([year, month, day, baseTime.hour, baseTime.minute, 
> baseTime.second, weekday, -1, -1])
>                                                       testTimeStamp = 
> testTimeStamp + 1
>                                                       test = 
> datetime.datetime.fromtimestamp (testTimeStamp)
>                                                       if (test.day != day or 
> test.weekday () != weekday):
>                                                               testTimeStamp = 
> -1
> 
>                                                       if (testTimeStamp > 0):
>                                                               if 
> (testTimeStamp > baseTimeStamp and (testTimeStamp < nextTimeStamp or 
> nextTimeStamp < 0)):
>                                                                       
> nextTimeStamp = testTimeStamp
> 
>                       if (nextTimeStamp > 0):
>                               nextTime = datetime.datetime.fromtimestamp 
> (nextTimeStamp)
>                               if (nextTime.day == baseTime.day and 
> nextTime.month == baseTime.month and nextTime.year == baseTime.year):
>                                       minMinute = baseTime.minute
>                                       minHour = baseTime.hour
>                               else:
>                                       minMinute = 0
>                                       minHour = 0
> 
>                               hour = -1
>                               for val in entryAttr [1]:
>                                       if (val >= minHour and (val < hour or 
> hour < 0)):
>                                               hour = val
> 
>                               minute = -1
>                               for val in entryAttr [0]:
>                                       if (val > minMinute and (val < minute 
> or minute < 0)):
>                                               minute = val
> 
>                               nextTimeStamp = time.mktime ([nextTime.year, 
> nextTime.month, nextTime.day, hour, minute, 0, nextTime.weekday (), -1, -1])
> 
>                               entryNextTime = time.strftime ("%x %X", 
> time.localtime (nextTimeStamp))
>                       else:
>                               entryNextTime = "Never"
> 
>                       model.set (model.append (), 0, entry.getId (), 1, 
> entry.isActive () == False, 2, entry.getName (), 3, entryNextTime, 4, 
> self.insensitiveColor)

reply via email to

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