[Tutor] Alarm Clock (suggestions please)

David david at abbottdavid.com
Tue Feb 3 04:53:50 CET 2009


Hi All,
As I am getting a little older, I sometimes take small naps to recharge 
my batteries:) Is this while loop OK? What kind of error checking should 
I use?
thanks
-david

<code>

#!/usr/bin/python

import time
import subprocess
import sys

doit = 1
alarmhour = int(raw_input("Please enter the hour. (24h): "))
alarmmin = int(raw_input("Please enter the minute. (01-59) "))

while(doit):
	mytime = list(time.localtime())
	hour = mytime[3]
	minute = mytime[4]
	if hour == alarmhour and minute == alarmmin:
		subprocess.call('mplayer -loop 9 ring.wav', shell=True)
		sys.exit()
doit = 0

</code>
-- 
Powered by Gentoo GNU/LINUX
http://www.linuxcrazy.com
pgp.mit.edu



More information about the Tutor mailing list