+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
+ omniorbUserPath = os.getenv("OMNIORB_USER_PATH")
+ kwargs = {}
+ if omniorbUserPath is not None:
+ kwargs["with_username"]=True
+ 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
+ os.environ['NSPORT'] = str(port)
+
+ # give the chance to the servers to shutdown properly
+ try:
+ import time
+ 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
+ if cleanup:
+ lcc.killOmniNames()
+ time.sleep(1)
+ pass
+ pass
+ except:
+ pass
+ pass
+