Salome HOME
projects
/
modules
/
kernel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
CMake: Sphinx: simplifying Win32 command
[modules/kernel.git]
/
bin
/
killSalomeWithPort.py
diff --git
a/bin/killSalomeWithPort.py
b/bin/killSalomeWithPort.py
index 57729aa88a3601a7e0a2ffd7647817b7acdfa1df..84774cef326c011c1713c1d34f3e1a1c2c56c27b 100755
(executable)
--- a/
bin/killSalomeWithPort.py
+++ b/
bin/killSalomeWithPort.py
@@
-1,6
+1,6
@@
#! /usr/bin/env python
# -*- coding: iso-8859-1 -*-
#! /usr/bin/env python
# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-201
2
CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-201
3
CEA/DEN, EDF R&D, OPEN CASCADE
#
# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#
# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@
-33,7
+33,6
@@
import os, sys, pickle, signal, commands,glob
from salome_utils import verbose
import os, sys, pickle, signal, commands,glob
from salome_utils import verbose
-import Utils_Identity
import salome_utils
def getPiDict(port,appname='salome',full=True,hidden=True,hostname=None):
import salome_utils
def getPiDict(port,appname='salome',full=True,hidden=True,hostname=None):
@@
-82,25
+81,23
@@
def getPiDict(port,appname='salome',full=True,hidden=True,hostname=None):
def appliCleanOmniOrbConfig(port):
"""
Remove omniorb config files related to the port in SALOME application:
def appliCleanOmniOrbConfig(port):
"""
Remove omniorb config files related to the port in SALOME application:
- - ${
HOME}/${APPLI}/USERS
/.omniORB_${USER}_${HOSTNAME}_${NSPORT}.cfg
- - ${
HOME}/${APPLI}/USERS
/.omniORB_${USER}_last.cfg
+ - ${
OMNIORB_USER_PATH}
/.omniORB_${USER}_${HOSTNAME}_${NSPORT}.cfg
+ - ${
OMNIORB_USER_PATH}
/.omniORB_${USER}_last.cfg
the last is removed only if the link points to the first file.
"""
from salome_utils import generateFileName, getUserName
the last is removed only if the link points to the first file.
"""
from salome_utils import generateFileName, getUserName
- home = os.getenv("HOME")
- appli = os.getenv("APPLI")
- if appli is None:
+ omniorbUserPath = os.getenv("OMNIORB_USER_PATH")
+ if omniorbUserPath is None:
#Run outside application context
pass
else:
#Run outside application context
pass
else:
- dir = os.path.join(os.path.realpath(home), appli,"USERS")
- omniorb_config = generateFileName(dir, prefix="omniORB",
+ omniorb_config = generateFileName(omniorbUserPath, prefix="omniORB",
extension="cfg",
hidden=True,
with_username=True,
with_hostname=True,
with_port=port)
extension="cfg",
hidden=True,
with_username=True,
with_hostname=True,
with_port=port)
- last_running_config = generateFileName(
dir
, prefix="omniORB",
+ last_running_config = generateFileName(
omniorbUserPath
, prefix="omniORB",
with_username=True,
suffix="last",
extension="cfg",
with_username=True,
suffix="last",
extension="cfg",
@@
-117,11
+114,10
@@
def appliCleanOmniOrbConfig(port):
os.remove(omniorb_config)
pass
os.remove(omniorb_config)
pass
- if os.path.lexists(last_running_config):return
+ if os.path.lexists(last_running_config):return
#try to relink last.cfg to an existing config file if any
#try to relink last.cfg to an existing config file if any
- files = glob.glob(os.path.join(os.environ["HOME"],Utils_Identity.getapplipath(),
- "USERS",".omniORB_"+getUserName()+"_*.cfg"))
+ files = glob.glob(os.path.join(omniorbUserPath,".omniORB_"+getUserName()+"_*.cfg"))
current_config=None
current=0
for f in files:
current_config=None
current=0
for f in files:
@@
-137,47
+133,53
@@
def appliCleanOmniOrbConfig(port):
########## kills all salome processes with the given port ##########
########## kills all salome processes with the given port ##########
-def shutdownMyPort(port):
+def shutdownMyPort(port
, cleanup=True
):
"""
Shutdown SALOME session running on the specified port.
Parameters:
- port - port number
"""
if not port: return
"""
Shutdown SALOME session running on the specified port.
Parameters:
- port - port number
"""
if not port: return
-
+
from salome_utils import generateFileName
# set OMNIORB_CONFIG variable to the proper file
from salome_utils import generateFileName
# set OMNIORB_CONFIG variable to the proper file
- home = os.getenv("HOME")
- appli = os.getenv("APPLI")
+ omniorbUserPath = os.getenv("OMNIORB_USER_PATH")
kwargs = {}
kwargs = {}
- if appli is not None:
- home = os.path.join(os.path.realpath(home), appli,"USERS")
+ if omniorbUserPath is not None:
kwargs["with_username"]=True
kwargs["with_username"]=True
- pass
- omniorb_config = generateFileName(home, prefix="omniORB",
+ else:
+ omniorbUserPath = os.path.realpath(os.path.expanduser('~'))
+ omniorb_config = generateFileName(omniorbUserPath, prefix="omniORB",
extension="cfg",
hidden=True,
with_hostname=True,
with_port=port,
**kwargs)
os.environ['OMNIORB_CONFIG'] = omniorb_config
extension="cfg",
hidden=True,
with_hostname=True,
with_port=port,
**kwargs)
os.environ['OMNIORB_CONFIG'] = omniorb_config
+ os.environ['NSPORT'] = str(port)
# give the chance to the servers to shutdown properly
try:
import time
# give the chance to the servers to shutdown properly
try:
import time
- import salome_kernel
- orb, lcc, naming_service, cm = salome_kernel.salome_kernel_init()
+ from omniORB import CORBA
+ from LifeCycleCORBA import LifeCycleCORBA
# shutdown all
# shutdown all
+ orb = CORBA.ORB_init([''], CORBA.ORB_ID)
+ lcc = LifeCycleCORBA(orb)
lcc.shutdownServers()
# give some time to shutdown to complete
time.sleep(1)
# shutdown omniNames and notifd
lcc.shutdownServers()
# give some time to shutdown to complete
time.sleep(1)
# shutdown omniNames and notifd
- salome_kernel.LifeCycleCORBA.killOmniNames()
+ if cleanup:
+ lcc.killOmniNames()
+ time.sleep(1)
+ pass
+ pass
except:
pass
pass
except:
pass
pass
-
+
def killMyPort(port):
"""
Kill SALOME session running on the specified port.
def killMyPort(port):
"""
Kill SALOME session running on the specified port.
@@
-185,12
+187,12
@@
def killMyPort(port):
- port - port number
"""
from salome_utils import getShortHostName, getHostName
- port - port number
"""
from salome_utils import getShortHostName, getHostName
-
+
# try to shutdown session nomally
import threading, time
# try to shutdown session nomally
import threading, time
- threading.Thread(target=shutdownMyPort, args=(port,)).start()
+ 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)
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)
# new-style dot-prefixed pidict file
filedict = getPiDict(port, hidden=True)
# provide compatibility with old-style pidict file (not dot-prefixed)
@@
-218,7
+220,7
@@
def killMyPort(port):
suffix="Pid_omniNames",
extension="log",
with_port=port)
suffix="Pid_omniNames",
extension="log",
with_port=port)
- if not sys.platform == 'win32':
+ 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
cmd = 'pid=`ps -eo pid,command | egrep "[0-9] omniNames -start %s"` ; echo $pid > %s' % ( str(port), fpidomniNames )
a = os.system(cmd)
pass
@@
-255,7
+257,7
@@
def killMyPort(port):
try:
if sys.platform == "win32":
import win32pm
try:
if sys.platform == "win32":
import win32pm
- win32pm.killpid(int(pid),0)
+ win32pm.killpid(int(pid),0)
else:
os.kill(int(pid),signal.SIGKILL)
pass
else:
os.kill(int(pid),signal.SIGKILL)
pass
@@
-285,7
+287,7
@@
def killMyPort(port):
#
appliCleanOmniOrbConfig(port)
pass
#
appliCleanOmniOrbConfig(port)
pass
-
+
def killNotifdAndClean(port):
"""
Kill notifd daemon and clean application running on the specified port.
def killNotifdAndClean(port):
"""
Kill notifd daemon and clean application running on the specified port.
@@
-355,10
+357,19
@@
def killMyPortSpy(pid, port):
return
if __name__ == "__main__":
return
if __name__ == "__main__":
+ if len(sys.argv) < 2:
+ print "Usage: "
+ print " %s <port>" % os.path.basename(sys.argv[0])
+ print
+ print "Kills SALOME session running on specified <port>."
+ sys.exit(1)
+ pass
if sys.argv[1] == "--spy":
if sys.argv[1] == "--spy":
- pid = sys.argv[2]
- port = sys.argv[3]
- killMyPortSpy(pid, port)
+ if len(sys.argv) > 3:
+ pid = sys.argv[2]
+ port = sys.argv[3]
+ killMyPortSpy(pid, port)
+ pass
sys.exit(0)
pass
for port in sys.argv[1:]:
sys.exit(0)
pass
for port in sys.argv[1:]: