#! /usr/bin/env python
# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-2013 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
#Run outside application context
pass
else:
- dir = os.path.join(home, appli,"USERS")
+ dir = os.path.join(os.path.realpath(home), appli,"USERS")
omniorb_config = generateFileName(dir, prefix="omniORB",
extension="cfg",
hidden=True,
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
files = glob.glob(os.path.join(os.environ["HOME"],Utils_Identity.getapplipath(),
########## 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
-
+
from salome_utils import generateFileName
# set OMNIORB_CONFIG variable to the proper file
home = os.getenv("HOME")
appli = os.getenv("APPLI")
kwargs = {}
- if appli is not None:
- home = os.path.join(home, appli,"USERS")
+ if appli is not None:
+ home = os.path.join(os.path.realpath(home), appli,"USERS")
kwargs["with_username"]=True
pass
omniorb_config = generateFileName(home, prefix="omniORB",
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
- import salome_kernel
- orb, lcc, naming_service, cm = salome_kernel.salome_kernel_init()
+ from omniORB import CORBA
+ from LifeCycleCORBA import LifeCycleCORBA
# 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
- salome_kernel.LifeCycleCORBA.killOmniNames()
+ if cleanup:
+ lcc.killOmniNames()
+ time.sleep(1)
+ pass
+ pass
except:
pass
pass
-
+
def killMyPort(port):
"""
Kill SALOME session running on the specified port.
- port - port number
"""
from salome_utils import getShortHostName, getHostName
-
+
# 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)
-
+
# new-style dot-prefixed pidict file
filedict = getPiDict(port, hidden=True)
# provide compatibility with old-style pidict file (not dot-prefixed)
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
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
#
appliCleanOmniOrbConfig(port)
pass
-
+
def killNotifdAndClean(port):
"""
Kill notifd daemon and clean application running on the specified port.
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":
- 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:]:
#!/usr/bin/env python
# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-2013 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
#
import time
-import salome_kernel
-orb, lcc, naming_service, cm = salome_kernel.salome_kernel_init()
+from omniORB import CORBA
+from LifeCycleCORBA import *
+
+orb = CORBA.ORB_init([''], CORBA.ORB_ID)
+lcc = LifeCycleCORBA(orb)
lcc.shutdownServers()
-#give some time to shutdown to complete
time.sleep(1)
-salome_kernel.LifeCycleCORBA.killOmniNames()
+LifeCycleCORBA.killOmniNames()
+time.sleep(1)