Modified runsics.py so that status checking works with Python 2.6.6 on SL6

This was done by replacing subprocess.check_output() with
subprocess.Popen().communicate().
This commit is contained in:
Ferdi Franceschini
2013-05-16 06:30:37 +10:00
parent 3f75de6357
commit fc9f6f6152

View File

@@ -56,7 +56,7 @@ def start_cmd(server, args):
execenv.update(sicsenv['scriptval'])
else:
execenv.update(sicsenv[args.test])
start_str = 'sudo -Eu %s %s/SICServer -d %s' % (args.user, args.dir, args.config)
start_str = 'sudo -u %s %s/SICServer -d %s' % (args.user, args.dir, args.config)
# Suppress output if launching the script validator
if (server == 'scriptval'):
with open(os.devnull) as fp:
@@ -82,13 +82,13 @@ def stop_cmd(server, args):
if status_cmd(server, args):
print 'Failed to stop %s' % server
print 'Try harder dammit!'
subprocess.call(shlex.split('sudo -Eu root killall SICServer'))
subprocess.call(shlex.split('sudo -u root killall SICServer'))
else:
return
if status_cmd(server, args):
print 'Failed again!'
print 'Die damn you! DIE!!'
subprocess.call(shlex.split('sudo -Eu root killall -s15 SICServer'))
subprocess.call(shlex.split('sudo -u root killall -s15 SICServer'))
else:
return
if status_cmd(server, args):
@@ -101,9 +101,12 @@ def status_cmd(server, args):
sock = server_port[server]['server']
else:
sock = server_port[server]['server'] + inst_test_sockoffset[args.sockoffset]
status_cmd = 'sudo -Eu %s netstat -nltp' % args.user
with open(os.devnull) as fp:
netstat_str = subprocess.check_output(shlex.split(status_cmd), stderr=fp)
status_cmd = 'sudo -u %s netstat -nltp' % 'root'
netstat_str, err = subprocess.Popen(shlex.split(status_cmd), stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
# ffr: We can replace the previous Popen().communicate() line with the following two lines if Python is upgraded to V2.7
# with open(os.devnull) as fp:
# netstat_str = subprocess.check_output(shlex.split(status_cmd), stderr=fp)
#
#Find PID of SICServer listening on server port
m = re.search(':%d .* (\d+)\/SICServer' % sock, netstat_str)
if m: