472,992 Members | 3,492 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,992 software developers and data experts.

How to - scheduler.py

Hi,

I'm using windows XP and I`m wondering what is the best way to scheduled a start and stop time entered manually, let said btwn : Sep 06 10:00 2007 to Sep 06 11:00 2007. (I'm using windows XP). (Want just pure python script no task sheduler). Should I use ?:

./scheduler.py "sep 6 12:00 2007" "sep 6 13:00 2007" if so, how can I call a class ?

Tks
Sep 6 '07 #1
5 2730
bartonc
6,596 Expert 4TB
Hi,

I'm using windows XP and I`m wondering what is the best way to scheduled a start and stop time entered manually, let said btwn : Sep 06 10:00 2007 to Sep 06 11:00 2007. (I'm using windows XP). (Want just pure python script no task sheduler). Should I use ?:

./scheduler.py "sep 6 12:00 2007" "sep 6 13:00 2007" if so, how can I call a class ?

Tks
I haven't played with this much, but here are some of the things that you will need:
Expand|Select|Wrap|Line Numbers
  1. >>> import time
  2. >>> import sched
  3. >>> def timedAction(arg1):
  4. ...     print arg1
  5. ...     
  6. >>> s = sched.scheduler(time.time, time.sleep)
  7. >>> startTime = time.mktime(time.strptime("sep 6 18:25 2007", '%b %d %H:%M %Y'))
  8. >>> timer1 = s.enterabs(startTime, 0, timedAction, ("Hello world @ %f" %time.time(),))
  9. >>> startTime = time.mktime(time.strptime("sep 6 18:25 2007", '%b %d %H:%M %Y'))
  10. >>> timer1 = s.enterabs(startTime, 0, timedAction, ("Hello world @ %f" %time.time(),))
  11. >>> s.run()
  12. Hello world @ 1189122855.187000
Sep 7 '07 #2
Hello Bartonc,

What will be the right syntaxe if I want to add startDateTime = input_raw('Pls enter date and time : ') instead of a static date/time?
Sep 7 '07 #3
bartonc
6,596 Expert 4TB
Hello Bartonc,

What will be the right syntaxe if I want to add startDateTime = input_raw('Pls enter date and time : ') instead of a static date/time?
Expand|Select|Wrap|Line Numbers
  1. while True:
  2.     startDateTime = input_raw('Pls enter date and time Mo Day HH:MM YYYY: ')
  3.     try:
  4.         timeTuple = time.strptime(startDateTime, '%b %d %H:%M %Y')
  5.         break
  6.     except ValueError:
  7.         print "That is not a valid date. Please use Mo Day HH:MM YYYY."
  8. startTime = time.mktime(timeTuple)
(Which, by the way, is a very odd date and time format.) Although you are asking a lot of the user to get the date typed in correctly and could do better checking.
Sep 7 '07 #4
Hi Bartonc,

looks nice but I need to put another raw_input to stop the scheduler,
how should look the syntax now ???
Sep 7 '07 #5
bartonc
6,596 Expert 4TB
Hi Bartonc,

looks nice but I need to put another raw_input to stop the scheduler,
how should look the syntax now ???
Then it's time to make it a funtion:
Expand|Select|Wrap|Line Numbers
  1. myOddDateFormat = "Mo Day HH:MM YYYY"
  2.  
  3. def GetDate(prompt):
  4.     while True:
  5.         startDateTime = input_raw("%s :%s: " %(prompt, myOddDateFormat))
  6.         try:
  7.             timeTuple = time.strptime(startDateTime, '%b %d %H:%M %Y')
  8.             break
  9.         except ValueError:
  10.             print "That is not a valid date. Please use %s." %myOddDateFormat
  11.     return time.mktime(timeTuple)
  12.  
  13. startTime = GetDate('Pls enter starting date and time')
  14. stopTime = GetDate('Pls enter stopping date and time')
Sep 7 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: keepyourstupidspam | last post by:
Anyone know of a reliable design for a Windows C++ Task Scheduler Class. The scheduler will expose a member function that will add schedules, its parameters will be an interval to run the tasks...
1
by: Mike Thomas | last post by:
I want to start this thread again - on my first attempt I was a little ambiguous and was not able to get the answer I need. I am trying to start Access 2000 on Windows NT 2000 Server by using the...
1
by: Neil Ginsberg | last post by:
I am having trouble using Windows Scheduler with an A2K database that has a password. The password is a db password, not a user-level security password. I have a routine I am looking for Scheduler...
4
by: LongBow | last post by:
Hello all, I have been working on my first embedded project which has been exciting and stressfull at the same time. My task now is to develop a good scheduler for transmitting ARINC labels....
7
by: Shane Story | last post by:
Have an app and would like to allow easy addition of MYAPP.EXE /F /P (for example) my prog with command line args, as a job to be run. Would like to make it easier on the user to run the app. ...
8
by: VMI | last post by:
I'm searching for a way to build a scheduler that will store its data in sql server. I've searched google but it mostly displays sites that sell scheduler controls. Anyone know of any sites that...
3
by: mayur_hirpara | last post by:
Hi, I am writing a VB.NET application. It is a Windows application at the moment. The application contains a button. the click event of button perform a long running task. It needs to be started...
2
by: yamca | last post by:
I want to write a task scheduler. But i cant make the logic between the scheduler and tasks. For example a have an external process which can add and delete tasks from scheduler. Every task has...
4
by: Sid Price | last post by:
Is there a .NET (2003) class available somewhere that might provide a comprehensive task scheduler with a better granularity than the one minute of the built-in scheduler on XP? Even down to 15...
1
by: =?Utf-8?B?YXVzdGlyb2I=?= | last post by:
Hi, While I realise that this may not be a very nice solution architecturally, I kick off a Scheduler in an ASP.NET 2.0 webservice in Application_Start() which is supposed to call a stored proc...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.