-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathscheduler.py
42 lines (36 loc) · 908 Bytes
/
scheduler.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import subprocess
import time
import os
import signal
import random
import sys
playlist = __import__(sys.argv[1])
port = int(sys.argv[2])
WALLSIZEX = int(sys.argv[3])
WALLSIZEY = int(sys.argv[4])
pidfile='/tmp/animation_pids'
def abort(signal,frame,pids):
for pid in pids:
os.kill(pid,signal.SIGKILL)
signal.signal(signal.SIGINT, abort)
signal.pause
while 1:
reload(playlist)
pl=playlist.getPlaylist()
i = random.choice(pl)
t = i[0]
processlist=[]
pids=open(pidfile,"w")
pids.close()
for animation in i[1]:
p=subprocess.Popen(animation+['--port=%d' % port, '--wallsizex=%d' % WALLSIZEX, '--wallsizey=%d' % WALLSIZEY])
processlist.append(p)
print "[" + str(p.pid) + "] " + str(animation)
pids= open(pidfile,'a')
pids.write(str(p.pid)+"\n")
pids.close()
time.sleep(t)
for process in processlist:
process.kill()
print "next entry"
reload(playlist)