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):
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:
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
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:
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')