1 ##############################################################################
2 # Copyright (c) 2016 ZTE Corporation
3 # feng.xiaowei@zte.com.cn
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
11 possible_processes = [
12 'result_collection_api',
18 for proc in possible_processes:
19 query = 'ps -ef | grep {} | grep -v grep'.format(proc)
20 runnings = execute_with_output(query)
22 for running in runnings:
23 kill = 'kill -kill ' + running.split()[1]
24 execute_with_output(kill)
25 runnings = execute_with_output(query)
26 assert len(runnings) == 0, 'kill %s failed'.format(proc)
29 def install_dependencies():
30 execute_with_assert('pip install -r ../requirements.txt')
34 execute_with_assert('cd ../ && python setup.py install')
38 execute_with_assert('opnfv-testapi &')
41 def execute_with_output(cmd):
42 return subprocess.Popen(cmd, shell=True,
43 stdout=subprocess.PIPE).stdout.readlines()
46 def execute_with_assert(cmd):
47 execute_output = subprocess.call(cmd, shell=True)
48 assert execute_output == 0
51 if __name__ == '__main__':
53 install_dependencies()