From: vsr Date: Mon, 24 Jan 2011 15:40:00 +0000 (+0000) Subject: Fix regression: killSalomeWithPort does not kill sessions of the old versions of... X-Git-Tag: Start_BR_19998_21191~91 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f8aa7591486080e4299013480bf30d97ad93d1d5;p=modules%2Fkernel.git Fix regression: killSalomeWithPort does not kill sessions of the old versions of SALOME (pidict file format has been changed) --- diff --git a/bin/killSalome.py b/bin/killSalome.py index 74400406d..c9065d8f4 100755 --- a/bin/killSalome.py +++ b/bin/killSalome.py @@ -29,19 +29,24 @@ import os, sys, re, signal from killSalomeWithPort import killMyPort, getPiDict +from salome_utils import getHostName, getShortHostName def killAllPorts(): """ Kill all SALOME sessions belonging to the user. """ user = os.getenv('USER') + 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) - fpidict = fpidict.replace('#####', '(\d*)') + if hostname in fpidict: + fpidict = fpidict.replace(hostname, shostname+".*") + fpidict = fpidict.replace('#####', '(\d*)') fnamere = re.compile("^%s$" % fpidict) try: for f in os.listdir(dirpidict): @@ -56,9 +61,11 @@ def killAllPorts(): pass # provide compatibility with old-style pidict file (not dot-prefixed) #fpidict = getPiDict('(\d*)',hidden=False) - fpidict = getPiDict('#####',hidden=True) + fpidict = getPiDict('#####',hidden=False) dirpidict = os.path.dirname(fpidict) fpidict = os.path.basename(fpidict) + 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 1da181696..59c977a33 100755 --- a/bin/killSalomeWithPort.py +++ b/bin/killSalomeWithPort.py @@ -36,7 +36,7 @@ from launchConfigureParser import verbose import Utils_Identity import salome_utils -def getPiDict(port,appname='salome',full=True,hidden=True): +def getPiDict(port,appname='salome',full=True,hidden=True,hostname=None): """ Get file with list of SALOME processes. This file is located in the user's home directory @@ -54,7 +54,8 @@ def getPiDict(port,appname='salome',full=True,hidden=True): to support compatibility with older versions of SALOME """ from salome_utils import generateFileName, getTmpDir, getHostName - hostname = os.getenv("NSHOST") or getHostName() + if not hostname: + hostname = os.getenv("NSHOST") or getHostName() if full: # full path to the pidict file is requested if hidden: @@ -139,10 +140,15 @@ def killMyPort(port): Parameters: - port - port number """ + from salome_utils import getShortHostName # 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) + 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) + if not os.path.exists(filedict): filedict = getPiDict(port, hidden=False, hostname=getShortHostName()) # try: fpid = open(filedict, 'r')