+ pass
+
+def killMyPort(port):
+ """
+ Kill SALOME session running on the specified port.
+ Parameters:
+ - port - port number
+ """
+ from salome_utils import getShortHostName, getHostName
+
+ # try to shutdown session nomally
+ import threading, time
+ threading.Thread(target=shutdownMyPort, args=(port,False)).start()
+ time.sleep(3) # wait a little, then kill processes (should be done if shutdown procedure hangs up)
+
+ # 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 (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, 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')
+ #
+ from salome_utils import generateFileName
+ if sys.platform == "win32":
+ username = os.getenv( "USERNAME" )
+ else:
+ username = os.getenv('USER')
+ path = os.path.join('/tmp/logs', username)
+ fpidomniNames = generateFileName(path,
+ prefix="",
+ suffix="Pid_omniNames",
+ extension="log",
+ with_port=port)
+ if not sys.platform == 'win32':
+ cmd = 'pid=`ps -eo pid,command | egrep "[0-9] omniNames -start %s"` ; echo $pid > %s' % ( str(port), fpidomniNames )
+ a = os.system(cmd)
+ pass
+ try:
+ fpidomniNamesFile = open(fpidomniNames)
+ lines = fpidomniNamesFile.readlines()
+ fpidomniNamesFile.close()
+ os.remove(fpidomniNames)
+ for l in lines:
+ try:
+ pidfield = l.split()[0] # pid should be at the first position
+ if sys.platform == "win32":
+ import win32pm
+ if verbose(): print 'stop process '+pidfield+' : omniNames'
+ win32pm.killpid(int(pidfield),0)
+ else:
+ if verbose(): print 'stop process '+pidfield+' : omniNames'
+ os.kill(int(pidfield),signal.SIGKILL)
+ pass
+ pass
+ except:
+ pass
+ pass
+ pass
+ except:
+ pass
+ #