From 7ac2dd11f3310e611bf392e3c7d2613b2a35bc94 Mon Sep 17 00:00:00 2001 From: prascle Date: Fri, 31 Mar 2006 06:36:35 +0000 Subject: [PATCH] PR: add omniORB config files cleaning in case of SALOME application --- bin/killSalomeWithPort.py | 45 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/bin/killSalomeWithPort.py b/bin/killSalomeWithPort.py index bb1bec3b0..bf5ca5ef7 100755 --- a/bin/killSalomeWithPort.py +++ b/bin/killSalomeWithPort.py @@ -22,7 +22,39 @@ def getPiDict(port,appname='salome',full=True): filedict = os.getenv("HOME") + '/' + filedict return filedict +def appliCleanOmniOrbConfig(port): + """ + remove omniorb config files related to the port in SALOME application: + - ${HOME}/${APPLI}/.omniORB_${HOSTNAME}_${NSPORT}.cfg + - ${HOME}/${APPLI}/.omniORB_${HOSTNAME}_last.cfg + the last is removed only if the link points to the first file. + """ + from Utils_Identity import getShortHostName + appli=os.environ.get("APPLI") + if appli is None: + #Run outside application context + pass + else: + home = os.environ['HOME'] + home='%s/%s'%(home,appli) + hostname=getShortHostName() + omniorb_config = '%s/.omniORB_%s_%s.cfg'%(home,hostname, str(port)) + last_running_config = '%s/.omniORB_%s_last.cfg'%(home, hostname) + if os.access(last_running_config,os.F_OK): + pointedPath = os.readlink(last_running_config) + if pointedPath[0] != '/': + pointedPath=os.path.join(os.path.dirname(last_running_config), pointedPath) + if pointedPath == omniorb_config: + os.unlink(last_running_config) + pass + pass + if os.access(omniorb_config,os.F_OK): + os.remove(omniorb_config) + pass + pass + ########## kills all salome processes with the given port ########## + def killMyPort(port): filedict=getPiDict(port) found = 0 @@ -30,7 +62,7 @@ def killMyPort(port): fpid=open(filedict, 'r') found = 1 except: - print "le fichier %s des process SALOME n'est pas accessible"% filedict + print "file %s giving SALOME process id is not readable"% filedict pass if found: @@ -49,6 +81,7 @@ def killMyPort(port): pidfield = field except: pass + try: process_ids=pickle.load(fpid) fpid.close() @@ -59,11 +92,12 @@ def killMyPort(port): try: os.kill(int(pid),signal.SIGKILL) except: - print " ------------------ process %s : %s inexistant"% (pid, cmd[0]) + print " ------------------ process %s : %s not found"% (pid, cmd[0]) pass pass except: pass + os.remove(filedict) cmd='ps -eo pid,command | egrep "[0-9] omniNames -start '+str(port)+'" | sed -e "s%[^0-9]*\([0-9]*\) .*%\\1%g"' pid = commands.getoutput(cmd) @@ -72,7 +106,12 @@ def killMyPort(port): a = commands.getoutput("pid=`ps -eo pid,command | egrep \"[0-9] omniNames -start "+str(port)+"\" | sed -e \"s%[^0-9]*\([0-9]*\) .*%\\1%g\"`; kill -9 $pid") pid = commands.getoutput("ps -eo pid,command | egrep \"[0-9] omniNames -start "+str(port)+"\" | sed -e \"s%[^0-9]*\([0-9]*\) .*%\\1%g\"") print pid - + + pass + + appliCleanOmniOrbConfig(port) + pass + if __name__ == "__main__": for port in sys.argv[1:]: -- 2.39.2