-
Notifications
You must be signed in to change notification settings - Fork 0
/
kill_pyro_proc.py
45 lines (32 loc) · 964 Bytes
/
kill_pyro_proc.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
43
44
45
#!/usr/bin/env python
import sys, os
import subprocess
import traceback
proc2kill=[]
def killprocess(cmd):
output =subprocess.Popen(cmd.split(), stdout=subprocess.PIPE).communicate()[0]
print 'here is the result....:', output
def get_processes():
output=subprocess.Popen('ps -ux'.split(), stdout=subprocess.PIPE).communicate()[0]
myproc=[]
for a in output.split('\n'):
if a.find('python') != -1:
if a.find('testbedserver.py') != -1 or a.find('pyro_client.py') != -1:
print a
myproc.append(a)
myproc_num=[]
for p in myproc:
myproc_num.append(p.split()[1])
killcmd='kill -9 '
for p in myproc_num:
print p,
killcmd += str(p+' ')
return killcmd
if __name__ == "__main__":
try:
cmd=get_processes()
killprocess(cmd)
except Exception, e:
print str(e)
traceback.print_exc()
os._exit(44)