From 8bf8ff5d0989e3b089606f758d645c58a449c36b Mon Sep 17 00:00:00 2001 From: prascle Date: Tue, 18 Oct 2005 14:10:09 +0000 Subject: [PATCH] PR: killList procedure for containers used in tests --- bin/addToKillList.py | 73 ++++++++++++++----- src/LifeCycleCORBA/Test/TestLifeCycleCORBA.py | 5 +- 2 files changed, 60 insertions(+), 18 deletions(-) diff --git a/bin/addToKillList.py b/bin/addToKillList.py index 7dad20eb1..2d26f6698 100755 --- a/bin/addToKillList.py +++ b/bin/addToKillList.py @@ -1,26 +1,34 @@ #!/usr/bin/env python -import os, sys, pickle, string +import os, sys, pickle, string, signal ########## adds to the kill list of SALOME one more process ########## -def addToKillList(command_pid, command): - command=(command.split(" "))[0] - my_port = 2809 - try: - file = open(os.environ["OMNIORB_CONFIG"], "r") - s = file.read() - while len(s): - l = string.split(s, ":") - if string.split(l[0], " ")[0] == "ORBInitRef" or string.split(l[0], " ")[0] == "InitRef" : - my_port = int(l[len(l)-1]) - pass - s = file.read() +def findFileDict(): + if os.environ.has_key('NSPORT'): + my_port = os.environ['NSPORT'] pass - except: - pass - #print "myport = ", my_port - + else: + my_port = 2809 + try: + file = open(os.environ["OMNIORB_CONFIG"], "r") + s = file.read() + while len(s): + l = string.split(s, ":") + if string.split(l[0], " ")[0] == "ORBInitRef" or string.split(l[0], " ")[0] == "InitRef" : + my_port = int(l[len(l)-1]) + pass + s = file.read() + pass + pass + except: + pass + pass + print "myport = ", my_port + return my_port + +def addToKillList(command_pid, command): + my_port = findFileDict() filedict=os.getenv("HOME")+'/'+os.getenv('USER')+"_"+str(my_port)+'_SALOME_pidict' try: fpid=open(filedict, 'r') @@ -37,8 +45,11 @@ def addToKillList(command_pid, command): #print "see process %s : %s"% (pid, cmd[0]) if pid == command_pid: already_in=1 + pass + pass pass + command=(command.split(" "))[0] if already_in == 0: try: process_ids.append({command_pid: [command]}) @@ -49,6 +60,34 @@ def addToKillList(command_pid, command): print "addToKillList: can not add command %s to the kill list"% filedict pass pass + pass + +def killList(): + my_port = findFileDict() + filedict=os.getenv("HOME")+'/'+os.getenv('USER')+"_"+str(my_port)+'_SALOME_pidict' + try: + fpid=open(filedict, 'r') + process_ids=pickle.load(fpid) + fpid.close() + except: + process_ids=[{}] + pass + + for process_id in process_ids: + print process_id + for pid, cmd in process_id.items(): + print "stop process %s : %s"% (pid, cmd[0]) + try: + os.kill(int(pid),signal.SIGKILL) + except: + print " ------------------ process %s : %s inexistant"% (pid, cmd[0]) + pass + pass + pass + os.remove(filedict) + pass + + if __name__ == "__main__": print sys.argv diff --git a/src/LifeCycleCORBA/Test/TestLifeCycleCORBA.py b/src/LifeCycleCORBA/Test/TestLifeCycleCORBA.py index a1c7135fe..0b6d0e6a3 100644 --- a/src/LifeCycleCORBA/Test/TestLifeCycleCORBA.py +++ b/src/LifeCycleCORBA/Test/TestLifeCycleCORBA.py @@ -3,6 +3,7 @@ import sys, os,signal,string,commands import runSalome import orbmodule import TestKiller +import addToKillList # get SALOME environment : @@ -62,6 +63,8 @@ import Engines containerManager = clt.waitNS("/ContainerManager",Engines.ContainerManager) containerManager.Shutdown() -# kill Test process +# kill Test process + +addToKillList.killList() TestKiller.killProcess(runSalome.process_id) -- 2.39.2