replace many Popen calls with more modern subprocess.call

This commit is contained in:
Martin Konecny 2012-05-07 15:46:49 -04:00
parent ece93ac054
commit 8de8a0be33
4 changed files with 13 additions and 22 deletions

View file

@ -1,4 +1,4 @@
from subprocess import Popen import subprocess
import os import os
if os.geteuid() != 0: if os.geteuid() != 0:
@ -11,16 +11,11 @@ try:
os.makedirs("/var/tmp/airtime/media-monitor") os.makedirs("/var/tmp/airtime/media-monitor")
#update-rc.d init script #update-rc.d init script
p = Popen("update-rc.d airtime-media-monitor defaults >/dev/null 2>&1", shell=True) subprocess.call("update-rc.d airtime-media-monitor defaults >/dev/null 2>&1", shell=True)
sts = os.waitpid(p.pid, 0)[1]
#Start media-monitor daemon #Start media-monitor daemon
print "* Waiting for media-monitor processes to start..." print "* Waiting for media-monitor processes to start..."
"""
p = Popen("invoke-rc.d airtime-media-monitor stop", shell=True) subprocess.call("invoke-rc.d airtime-media-monitor start-no-monit", shell=True)
sts = os.waitpid(p.pid, 0)[1]
"""
p = Popen("invoke-rc.d airtime-media-monitor start-no-monit", shell=True)
sts = os.waitpid(p.pid, 0)[1]
except Exception, e: except Exception, e:
print e print e

View file

@ -1,4 +1,4 @@
from subprocess import Popen import subprocess
import os import os
import sys import sys
@ -9,8 +9,7 @@ if os.geteuid() != 0:
try: try:
print "Waiting for media-monitor processes to stop...", print "Waiting for media-monitor processes to stop...",
if (os.path.exists('/etc/init.d/airtime-media-monitor')): if (os.path.exists('/etc/init.d/airtime-media-monitor')):
p = Popen("invoke-rc.d airtime-media-monitor stop", shell=True) subprocess.call("invoke-rc.d airtime-media-monitor stop", shell=True)
sts = os.waitpid(p.pid, 0)[1]
print "OK" print "OK"
else: else:
print "Wasn't running" print "Wasn't running"

View file

@ -1,6 +1,7 @@
import platform import platform
import shutil import shutil
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
import subprocess
import sys import sys
import os import os
sys.path.append('/usr/lib/airtime/') sys.path.append('/usr/lib/airtime/')
@ -115,17 +116,14 @@ try:
print "Unable to connect to the Airtime server." print "Unable to connect to the Airtime server."
#initialize init.d scripts #initialize init.d scripts
p = Popen("update-rc.d airtime-playout defaults >/dev/null 2>&1", shell=True) subprocess.call("update-rc.d airtime-playout defaults >/dev/null 2>&1", shell=True)
sts = os.waitpid(p.pid, 0)[1]
#clear out an previous pypo cache #clear out an previous pypo cache
print "* Clearing previous pypo cache" print "* Clearing previous pypo cache"
p = Popen("rm -rf '/var/tmp/airtime/pypo/cache/scheduler/*' >/dev/null 2>&1", shell=True) subprocess.call("rm -rf '/var/tmp/airtime/pypo/cache/scheduler/*' >/dev/null 2>&1", shell=True)
sts = os.waitpid(p.pid, 0)[1]
print "* Waiting for pypo processes to start..." print "* Waiting for pypo processes to start..."
p = Popen("invoke-rc.d airtime-playout start-no-monit > /dev/null 2>&1", shell=True) subprocess.call("invoke-rc.d airtime-playout start-no-monit > /dev/null 2>&1", shell=True)
sts = os.waitpid(p.pid, 0)[1]
except Exception, e: except Exception, e:
print e print e

View file

@ -1,6 +1,6 @@
from subprocess import Popen
import os import os
import sys import sys
import subprocess
if os.geteuid() != 0: if os.geteuid() != 0:
print "Please run this as root." print "Please run this as root."
@ -10,8 +10,7 @@ try:
#stop pypo and liquidsoap processes #stop pypo and liquidsoap processes
print "Waiting for pypo processes to stop...", print "Waiting for pypo processes to stop...",
if (os.path.exists('/etc/init.d/airtime-playout')): if (os.path.exists('/etc/init.d/airtime-playout')):
p = Popen("invoke-rc.d airtime-playout stop", shell=True) subprocess.call("invoke-rc.d airtime-playout stop", shell=True)
sts = os.waitpid(p.pid, 0)[1]
print "OK" print "OK"
else: else:
print "Wasn't running" print "Wasn't running"