[SUCS Devel] Cron <root at xstream> nice python /usr/local/bin/listenAgain.py

Andrew Price welshbyte at sucs.org
Mon Jul 9 00:44:15 BST 2007


On 09/07/07 00:05, Cron Daemon wrote:
> Traceback (most recent call last):
>   File "/usr/local/bin/listenAgain.py", line 7, in ?
>     log = path+logs[-2]
> IndexError: list index out of range

Chris, I've applied the following (naive?) patch to your script to shut
it up at midnight:

--- listenAgain.py.old  2007-07-09 00:30:40.000000000 +0100
+++ listenAgain.py      2007-07-09 00:37:54.000000000 +0100
@@ -1,9 +1,12 @@
 import os
+import sys
 import time
 import subprocess
 path = time.strftime('/home/icecast/logs/%Y/%m/%d/')
 logs = os.listdir(path)
 logs.sort()
+if len(logs) < 2:
+    sys.exit(0)
 log = path+logs[-2]
 when = time.strftime('%A-'+logs[-2][:2]+':00')
 logfile = file('listenAgain.log-'+when,'w')




More information about the Devel mailing list