X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=test%2F_testTools%2Ftools.py;h=2930b99601f8fb1bfe8a044c80bde19328808ac1;hb=5878e27c0081e371307cb7b7d9d72322c112bf2d;hp=6d13ac20339d8cd59e1872d6dd5d56b134138d7c;hpb=a3c9eb45aa029182bbe6e2d31c2957cc06bf293d;p=tools%2Fsat.git diff --git a/test/_testTools/tools.py b/test/_testTools/tools.py index 6d13ac2..2930b99 100644 --- a/test/_testTools/tools.py +++ b/test/_testTools/tools.py @@ -19,6 +19,7 @@ import tempfile import sys import subprocess +import time class outRedirection(): '''redirection of standart output @@ -53,7 +54,7 @@ def kill9(pid): def check_proc_existence_and_kill(regex): cmd = 'ps aux | grep "' + regex + '"' - psRes = subprocess.check_output(cmd, shell=True) + psRes = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).communicate()[0] psRes = psRes.split('\n') for line in psRes: if 'grep' in line or len(line) == 0: @@ -62,4 +63,15 @@ def check_proc_existence_and_kill(regex): pid = line2[1] kill9(pid) return pid - return 0 \ No newline at end of file + return 0 + +def check_proc_existence_and_kill_multi(regex, nb_kills, time_between_two_checks = 1): + found = False + i = 0 + while not found and i < nb_kills : + found = check_proc_existence_and_kill(regex) + if found: + return found + time.sleep(time_between_two_checks) + i+=1 + return 0 \ No newline at end of file