From af43d3d97210ecab419f74457df317d13060c7ca Mon Sep 17 00:00:00 2001 From: vsr Date: Mon, 7 Nov 2005 12:42:32 +0000 Subject: [PATCH] Fix PAL9538 --- bin/killSalome.py | 14 +++++++------- bin/killSalomeWithPort.py | 15 ++++++++++++++- bin/runSalome.py | 10 ++++------ 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/bin/killSalome.py b/bin/killSalome.py index 7ed1d6372..d03c8f98c 100755 --- a/bin/killSalome.py +++ b/bin/killSalome.py @@ -1,16 +1,16 @@ #!/usr/bin/env python -import os, string, sys +import os, string, sys, re -from killSalomeWithPort import killMyPort +from killSalomeWithPort import killMyPort, getPiDict def killAllPorts(): user = os.getenv('USER') + filedict = "^%s$"%(getPiDict('(\d*)',full=False)) + fnamere = re.compile(filedict) for file in os.listdir(os.getenv("HOME")): - l = string.split(file, "_") - if len(l) >= 4: - if file[:len(user)] == user: - if l[len(l)-2] == "SALOME" and l[len(l)-1] == "pidict": - killMyPort(l[len(l)-3]) + mo = re.match(fnamere,file) + if mo and len(mo.groups()): + killMyPort(mo.groups()[0]) pass if __name__ == "__main__": diff --git a/bin/killSalomeWithPort.py b/bin/killSalomeWithPort.py index e3fdea77e..7cc60a73d 100755 --- a/bin/killSalomeWithPort.py +++ b/bin/killSalomeWithPort.py @@ -1,9 +1,22 @@ #!/usr/bin/env python import os, sys, pickle, signal, commands +def getPiDict(port,appname='salome',full=True): + filedict = [] + filedict.append( os.getenv('USER') ) # user name + filedict.append( os.getenv('HOSTNAME') ) # host name + filedict.append( str(port) ) # port number + filedict.append( appname.upper() ) # application name + filedict.append( 'pidict' ) # constant part + + filedict = '_'.join(filedict) + if full: + filedict = os.getenv("HOME") + '/' + filedict + return filedict + ########## kills all salome processes with the given port ########## def killMyPort(port): - filedict=os.getenv("HOME")+'/'+os.getenv('USER')+"_"+port+'_SALOME_pidict' + filedict=getPiDict(port) found = 0 try: fpid=open(filedict, 'r') diff --git a/bin/runSalome.py b/bin/runSalome.py index 0827efa50..6e7b0938e 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -660,12 +660,10 @@ def useSalome(args, modules_list, modules_root_dir): print "--- erreur au lancement Salome ---" #print process_id - -# filedict = '/tmp/' + os.getenv('USER') + "_" + str(args['port']) \ -# + '_' + args['appname'].upper() + '_pidict' -# replaced args['appname'] by "SALOME" because in killSalome.py use of 'SALOME' in file name is hardcoded. - filedict = os.getenv("HOME") + '/' + os.getenv('USER') + "_" + str(args['port']) \ - + '_' + 'SALOME' + '_pidict' + + from killSalomeWithPort import getPiDict + filedict = getPiDict(args['port']) + process_ids = [] try: fpid=open(filedict, 'r') -- 2.39.2