Salome HOME
Correct the misprints in the README files. See https://codev-tuleap.cea.fr/plugins...
[tools/sat.git] / test / _testTools / tools.py
index 6d13ac20339d8cd59e1872d6dd5d56b134138d7c..2930b99601f8fb1bfe8a044c80bde19328808ac1 100644 (file)
@@ -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