Subdomain Posts
Recent Posts
Bash | 8 sec ago
None | 1 min ago
Python | 1 min ago
Python | 1 min ago
INI file | 1 min ago
None | 1 min ago
ASM (NASM) | 2 min ago
Bash | 2 min ago
Bash | 2 min ago
None | 2 min ago
Sitereport
Find cool info about any domain on the internet?
visit sitereport
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
Learn a little bit about the new Pastebin.com on our help page. hide message
By Dick Moores on the 10th of Sep 2008 07:27:16 PM Download | Raw | Embed | Report
  1. #!/usr/bin/env python
  2. # coding=utf-8
  3. # KUOW.py
  4. # with help from János Juhász on Tutor list
  5. # see http://thread.gmane.org/gmane.comp.python.tutor/46607
  6.  
  7. """
  8. Start KUOW streaming audio on my computer starting at a time I set
  9. """
  10. import time
  11. import os
  12.  
  13. print \
  14. """
  15. Enter starting time as hh:mm or h:mm. However, if want to start
  16. listening/recording on the hour, you may enter just that hour in 1 or 2 digits.
  17. E.g. 4:00 as 4 or 04, 22:00 as 22
  18.  
  19. The program allows 30 seconds to start bringing in a KUOW program, so the
  20. starting time entered is actually converted to a time 30 seconds earlier.
  21. E.g. 04:00 becomes 3:59:30, and 22:30 becomes 22:29:30
  22. """
  23. timeStart = raw_input("Enter starting time: ")
  24.  
  25. #cases such as "4" or "4:30" -- puts a "0" in front of entered hour
  26. if len(timeStart) == 1 or len(timeStart) == 4:
  27.     timeStart = "0" + timeStart
  28.  
  29. #cases such as 02, or 10
  30. if len(timeStart) == 2:
  31.     if timeStart == "00":
  32.         timeStart = "23"
  33.     else:
  34.         timeStart = int(timeStart) - 1
  35.     timeStart = str(timeStart) + ":59:30"
  36.  
  37. #cases such as 03:00, 13:30
  38. elif len(timeStart) == 5:
  39.     hour = timeStart[:2]
  40.     min = timeStart[3:5]
  41.     if min == "00":
  42.         min = "60"
  43.         hour = str(int(hour) - 1)
  44.     min = str(int(min) -1)
  45.     if len(min) == 1:
  46.         min = "0" + min
  47.     timeStart = hour + ":" + min + ":30"
  48.  
  49. print "starting time set as", timeStart
  50.  
  51. b = timeStart
  52.  
  53. (bhour, bmin, bsec) = b.split(':')
  54. bsec = int(bsec) + int(bmin)*60 + int(bhour)*3600
  55.  
  56. act = time.localtime()
  57. actsec = act.tm_sec + act.tm_min*60 + act.tm_hour*3600
  58. wait = bsec - actsec
  59. if wait < 0: # startTime is in next day
  60.     wait += 3600*24
  61. print "wait is", wait
  62. time.sleep(wait)
  63. print 'Starting now'
  64. print "Starting now, at", time.strftime('%H:%M:%S')
  65.  
  66. os.startfile('http://www.kuow.org/real.ram')
Submit a correction or amendment below. Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: