At 02:09 PM 2/29/2008, János Juhász wrote:
>
>import time
>b = '20:00:00'
>
>(bhour, bmin, bsec) = b.split(':')
>bsec = int(bsec) + int(bmin)*60 + int(bhour)*360
>
>while True:
> act = time.localtime()
> actsec = act.tm_sec + act.tm_min*60 + act.tm_hour*360
> wait = bsec - actsec
> if wait < 0:
> wait += 360*24 # it will be tomorrow
> time.sleep(wait)
> print 'I am doing!'
> break
Ah, very nice! (But all the '360's should be '3600', of course.)
Also, there's no longer any need for the loop.
So:
=========================================
#!/usr/bin/env python
#coding=utf-8
# KCTS.py
import time, os
timeStart = raw_input("Enter starting time as hh:mm:ss ")
if timeStart == "":
timeStart = "19:59:25"
print "starting time set as", timeStart
b = timeStart
(bhour, bmin, bsec) = b.split(':')
bsec = int(bsec) + int(bmin)*60 + int(bhour)*3600
act = time.localtime()
actsec = act.tm_sec + act.tm_min*60 + act.tm_hour*3600
wait = bsec - actsec
if wait < 0: # startTime is in next day
wait += 3600*24
print "wait is", wait
time.sleep(wait)
print 'Starting now'
os.startfile('http://www.kuow.org/real.ram')
=================================================
I wish I knew how to change that last line so that it would do what
"E:\Programs\Real Player\realplay.exe" http://www.kuow.org/real.ram
does at the command line--open Real Player at KUOW without calling my browser.
Dick Moores
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor