From: vsr Date: Thu, 3 Nov 2005 07:09:15 +0000 (+0000) Subject: PAL9538 X-Git-Tag: V2_2_6~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=05d5f2969a8a45e0c3ae22ca979d8f3c2ec9aa19;p=modules%2Fkernel.git PAL9538 --- 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 bf02709cf..221ba981e 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 a9bd92370..c3ac66070 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -673,10 +673,10 @@ def useSalome(args, modules_list, modules_root_dir): print "--- erreur au lancement Salome ---" #print process_id - - filedict = os.getenv("HOME") + '/' + os.getenv('USER') + "_" + str(args['port']) \ - + '_' + args['appname'].upper() + '_pidict' - + + from killSalomeWithPort import getPiDict + filedict = getPiDict(args['port'], args['appname']) + process_ids = [] try: fpid=open(filedict, 'r')