473,387 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 2737
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...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.