From: vtn Date: Mon, 1 Apr 2013 13:34:10 +0000 (+0000) Subject: Crash of tests on Windows X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2FBR_PPGP_BETA1;p=modules%2Fkernel.git Crash of tests on Windows --- diff --git a/bin/killSalomeWithPort.py b/bin/killSalomeWithPort.py index a8a046904..174fb00f3 100755 --- a/bin/killSalomeWithPort.py +++ b/bin/killSalomeWithPort.py @@ -1,6 +1,6 @@ #! /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 @@ -93,7 +93,7 @@ def appliCleanOmniOrbConfig(port): #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, @@ -117,7 +117,7 @@ def appliCleanOmniOrbConfig(port): 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(), @@ -137,22 +137,22 @@ def appliCleanOmniOrbConfig(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 - + 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", @@ -162,22 +162,29 @@ def shutdownMyPort(port): 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. @@ -185,12 +192,12 @@ def killMyPort(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) @@ -218,7 +225,7 @@ def killMyPort(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 @@ -255,7 +262,7 @@ def killMyPort(port): 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 @@ -285,7 +292,7 @@ def killMyPort(port): # appliCleanOmniOrbConfig(port) pass - + def killNotifdAndClean(port): """ Kill notifd daemon and clean application running on the specified port. @@ -355,10 +362,19 @@ def killMyPortSpy(pid, port): return if __name__ == "__main__": + if len(sys.argv) < 2: + print "Usage: " + print " %s " % os.path.basename(sys.argv[0]) + print + print "Kills SALOME session running on specified ." + 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:]: diff --git a/bin/salome_utils.py b/bin/salome_utils.py index 95e87f42c..dc79fb1c6 100644 --- a/bin/salome_utils.py +++ b/bin/salome_utils.py @@ -1,5 +1,5 @@ # -*- 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 # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -194,8 +194,11 @@ def getPortNumber(use_default=True): return int( os.getenv( "NSPORT" ) ) except: pass - port = getPortFromORBcfg() - if port is not None: return port + try: + port = int( getPortFromORBcfg() ) + if port is not None: return port + except: + pass if use_default: return 2809 # '2809' is default port number return None diff --git a/bin/shutdownSalome.py b/bin/shutdownSalome.py index b7d319696..e4425e315 100755 --- a/bin/shutdownSalome.py +++ b/bin/shutdownSalome.py @@ -1,6 +1,6 @@ #!/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 @@ -27,9 +27,12 @@ # 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) diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx index 2afca3b7f..afd7e6f63 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx @@ -550,6 +550,7 @@ void SALOME_LifeCycleCORBA::shutdownServers() if (!CORBA::is_nil(session)) { pid = session->getPID(); + session->Shutdown(); } } @@ -644,6 +645,7 @@ void SALOME_LifeCycleCORBA::shutdownServers() // ignore and continue } + /* // 6) Session if ( !CORBA::is_nil( session ) ) { try @@ -655,6 +657,7 @@ void SALOME_LifeCycleCORBA::shutdownServers() // ignore and continue } } + */ // 7) Logger int argc = 0;