From: vsr Date: Tue, 25 Jan 2011 06:49:15 +0000 (+0000) Subject: Fix regression: killSalomeWithPort does not kill sessions of the old versions of... X-Git-Tag: Start_BR_19998_21191~90 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e45d5aee405e8caa5e5a8aaa8e1f9993c98cc171;p=modules%2Fkernel.git Fix regression: killSalomeWithPort does not kill sessions of the old versions of SALOME (pidict file format has been changed) Additional change to revert back original behavior --- diff --git a/bin/killSalome.py b/bin/killSalome.py index c9065d8f4..4826e1bf9 100755 --- a/bin/killSalome.py +++ b/bin/killSalome.py @@ -29,23 +29,23 @@ import os, sys, re, signal from killSalomeWithPort import killMyPort, getPiDict -from salome_utils import getHostName, getShortHostName +#from salome_utils import getHostName, getShortHostName def killAllPorts(): """ Kill all SALOME sessions belonging to the user. """ user = os.getenv('USER') - hostname = getHostName() - shostname = getShortHostName() + #hostname = getHostName() + #shostname = getShortHostName() # new-style dot-prefixed pidict file #fpidict = getPiDict('(\d*)',hidden=True) #problem with WIN32 path slashes fpidict = getPiDict('#####',hidden=True) dirpidict = os.path.dirname(fpidict) fpidict = os.path.basename(fpidict) - if hostname in fpidict: - fpidict = fpidict.replace(hostname, shostname+".*") + #if hostname in fpidict: + # fpidict = fpidict.replace(hostname, shostname+".*") fpidict = fpidict.replace('#####', '(\d*)') fnamere = re.compile("^%s$" % fpidict) try: @@ -64,8 +64,8 @@ def killAllPorts(): fpidict = getPiDict('#####',hidden=False) dirpidict = os.path.dirname(fpidict) fpidict = os.path.basename(fpidict) - if hostname in fpidict: - fpidict = fpidict.replace(hostname, shostname+".*") + #if hostname in fpidict: + # fpidict = fpidict.replace(hostname, shostname+".*") fpidict = fpidict.replace('#####', '(\d*)') fnamere = re.compile("^%s$" % fpidict) try: diff --git a/bin/killSalomeWithPort.py b/bin/killSalomeWithPort.py index 59c977a33..6eeceec53 100755 --- a/bin/killSalomeWithPort.py +++ b/bin/killSalomeWithPort.py @@ -53,9 +53,12 @@ def getPiDict(port,appname='salome',full=True,hidden=True,hostname=None): - hidden : if True, file name is prefixed with . (dot) symbol; this internal parameter is used to support compatibility with older versions of SALOME """ - from salome_utils import generateFileName, getTmpDir, getHostName + from salome_utils import generateFileName, getTmpDir + dir = "" if not hostname: - hostname = os.getenv("NSHOST") or getHostName() + hostname = os.getenv("NSHOST") + if hostname: hostname = hostname.split(".")[0] + pass if full: # full path to the pidict file is requested if hidden: @@ -72,7 +75,7 @@ def getPiDict(port,appname='salome',full=True,hidden=True,hostname=None): suffix="pidict", hidden=hidden, with_username=True, - with_hostname=hostname, + with_hostname=hostname or True, with_port=port, with_app=appname.upper()) @@ -140,15 +143,19 @@ def killMyPort(port): Parameters: - port - port number """ - from salome_utils import getShortHostName + from salome_utils import getShortHostName, getHostName # new-style dot-prefixed pidict file filedict = getPiDict(port, hidden=True) # provide compatibility with old-style pidict file (not dot-prefixed) if not os.path.exists(filedict): filedict = getPiDict(port, hidden=False) - # provide compatibility with old-style pidict file (shost hostname) + # provide compatibility with old-style pidict file (short hostname) if not os.path.exists(filedict): filedict = getPiDict(port, hidden=True, hostname=getShortHostName()) - # provide compatibility with old-style pidict file (not dot-prefixed, shost hostname) + # provide compatibility with old-style pidict file (not dot-prefixed, short hostname) if not os.path.exists(filedict): filedict = getPiDict(port, hidden=False, hostname=getShortHostName()) + # provide compatibility with old-style pidict file (long hostname) + if not os.path.exists(filedict): filedict = getPiDict(port, hidden=True, hostname=getHostName()) + # provide compatibility with old-style pidict file (not dot-prefixed, long hostname) + if not os.path.exists(filedict): filedict = getPiDict(port, hidden=False, hostname=getHostName()) # try: fpid = open(filedict, 'r')