+ os.remove(filedict)
+ pass
+#
+
+def __guessPiDictFilename(port):
+ from salome_utils import getShortHostName, getHostName
+ filedicts = [
+ # new-style dot-prefixed pidict file
+ getPiDict(port, hidden=True),
+ # provide compatibility with old-style pidict file (not dot-prefixed)
+ getPiDict(port, hidden=False),
+ # provide compatibility with old-style pidict file (short hostname)
+ getPiDict(port, hidden=True, hostname=getShortHostName()),
+ # provide compatibility with old-style pidict file (not dot-prefixed, short hostname
+ getPiDict(port, hidden=False, hostname=getShortHostName()),
+ # provide compatibility with old-style pidict file (long hostname)
+ getPiDict(port, hidden=True, hostname=getHostName()),
+ # provide compatibility with old-style pidict file (not dot-prefixed, long hostname)
+ getPiDict(port, hidden=False, hostname=getHostName())
+ ]
+
+ log_msg = ""
+ for filedict in filedicts:
+ log_msg += "Trying %s..."%filedict
+ if os.path.exists(filedict):
+ log_msg += " ... OK\n"
+ break
+ else:
+ log_msg += " ... not found\n"
+
+ if verbose():
+ print(log_msg)
+
+ return filedict
+#
+
+def killMyPort(port):
+ """
+ Kill SALOME session running on the specified port.
+ Parameters:
+ - port - port number
+ """
+ # bug fix: ensure port is an integer
+ if port:
+ port = int(port)
+
+ try:
+ import PortManager # do not remove! Test for PortManager availability!
+ filedict = getPiDict(port)
+ if not os.path.isfile(filedict): # removed by previous call, see (1)
+ if verbose():
+ print("SALOME on port %s: already removed by previous call"%port)
+ # Remove port from PortManager config file
+ try:
+ from PortManager import releasePort
+ if verbose():
+ print("Removing port from PortManager configuration file")
+ releasePort(port)
+ except ImportError:
+ pass
+ return