[Tutor] Tutor Digest, Vol 126, Issue 86
Crush
crushed26 at gmail.com
Sun Aug 31 04:32:07 CEST 2014
Thank you Allan for your criticism. Please see the below changes. As far as the embedded loops, I know no other way to achieve the same out come.
def kill_proc(process1, process2):
i = psutil.Popen(["ps", "cax"], stdout=PIPE)
out, err = i.communicate()
for proc in psutil.process_iter():
if proc.name == process1 and process2:
proc.kill()
while True:
while count < 15:
count += 1
kill_proc("bmdplay", "avconv")
print "Starting the script", count
time.sleep(2)
p = subprocess.Popen("/Downloads/bmdtools/test_loop.sh",
shell=True, stderr=PIPE)
for line in p.stderr:
print line
if "Segmentation" in line:
kill_proc("bmdplay", "avconv")
while restart < 3:
restart += 1
time.sleep(2)
q =
subprocess.Popen("/Downloads/bmdtools/test_loop.sh", shell=True,
stderr=PIPE)
for line in q.stderr:
print line
if restart == 3:
# send email saying so
sys.exit()
if "storing 0x" in line:
kill_proc("bmdplay", "avconv")
while restart < 3:
restart += 1
sleep.time(2)
r =
subprocess.Popen("/Downloads/bmdtools/test_loop.sh", shell=True,
stderr=PIPE)
for line in r.stderr:
print line
if restart == 3:
# send email saying so
sys.exit()
if count == 10:
print "Going to sleep, will try again in..."
#send email saying so
time.sleep(2)
if count == 15:
# send email saying so
print "Gave up"
break
More information about the Tutor
mailing list