4 from sqlobject
import *
6 from datetime
import datetime
7 from time
import strptime
9 # Import variables from config file.
12 class playlists(SQLObject
):
15 description
= StringCol()
19 wednesday
= StringCol()
20 thursday
= StringCol()
22 saturday
= StringCol()
27 """file like for writes with auto flush after each write
28 to ensure that everything is logged, even during an
30 def __init__(self
, f
):
37 #change to data directory if needed
38 os
.chdir("/mnt/icebreaker/")
39 #redirect outputs to a logfile
40 sys
.stdout
= sys
.stderr
= Log(open(LOGFILE
, 'a+'))
41 #ensure the that the daemon runs a normal user
42 # os.setegid(100) #set group
43 # os.seteuid(1000) #set user
44 #change all 1's to 0 in current
47 n
=datetime
.now().strftime("%H:%M")
50 #check playlists table for list
51 #put in a loop, iterate through the database and parse all times, comparing starts.
53 start
= #time from playlists :: compare to current time, use timedelta
54 stop
= #time from playlists :: find way to make it stick
55 # convert string time to real time object
56 start1
=datetime
.time(datetime(*strptime(start
, "%H:%M")[0:6])).strftime("%H:%M")
57 stop1
=datetime
.time(datetime(*strptime(stop
, "%H:%M")[0:6])).strftime("%H:%M")
59 # make days in columns
60 # time in tuples per playlist :: make in [start:stop],[start:stop] form?
64 # set a boolean to 'list'
66 #### Move this to list script
70 #change 0 for current list to 1
73 if __name__
== "__main__":
74 # do the UNIX double-fork magic, see Stevens' "Advanced
75 # Programming in the UNIX Environment" for details (ISBN 0201563177)
82 print >>sys
.stderr
, "fork #1 failed: %d (%s)" % (e
.errno
, e
.strerror
)
85 # decouple from parent environment
86 os
.chdir("/") #don't prevent unmounting....
94 # exit from second parent, print eventual PID before
95 #print "Daemon PID %d" % pid
96 open(PIDFILE
,'w').write("%d"%pid
)
99 print >>sys
.stderr
, "fork #2 failed: %d (%s)" % (e
.errno
, e
.strerror
)
102 # start the daemon main loop