]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Add SALOME_USE_PORTMANAGER option in CMake
authoraguerre <aguerre>
Thu, 7 Nov 2013 18:18:59 +0000 (18:18 +0000)
committeraguerre <aguerre>
Thu, 7 Nov 2013 18:18:59 +0000 (18:18 +0000)
CMakeLists.txt
SalomeKERNELConfig.cmake.in
bin/CMakeLists.txt
bin/PortManager.py
bin/killSalomeWithPort.py
bin/launchConfigureParser.py
bin/searchFreePort.py
src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx

index 6288bb1f3111dd5e223b8fc091eb4e1edc1d7615..2b643425c2d76afb1d777c3df4c78d807b9c4047 100755 (executable)
@@ -63,7 +63,8 @@ OPTION(SALOME_USE_LIBBATCH "Use LibBatch in KERNEL" OFF)
 OPTION(SALOME_USE_SIMAN "Add SIMAN support" OFF)
 OPTION(SALOME_PACO_PARALLEL "Build with PACO (implies SALOME_USE_MPI)" OFF)
 OPTION(SALOME_LAUNCHER_ONLY "Build only the Launcher part" OFF)
-MARK_AS_ADVANCED(SALOME_LIGHT_ONLY SALOME_USE_LIBBATCH SALOME_USE_SIMAN SALOME_PACO_PARALLEL SALOME_LAUNCHER_ONLY)
+OPTION(SALOME_USE_PORTMANAGER "Add PortManager support" OFF)
+MARK_AS_ADVANCED(SALOME_LIGHT_ONLY SALOME_USE_LIBBATCH SALOME_USE_SIMAN SALOME_PACO_PARALLEL SALOME_LAUNCHER_ONLY SALOME_USE_PORTMANAGER)
 
 # Required prerequisites
 #   Find "big" prerequisites first - they reference themselves many others
@@ -95,7 +96,7 @@ ENDIF()
 IF(NOT SALOME_LIGHT_ONLY)
   FIND_PACKAGE(SalomeOmniORB REQUIRED)
   FIND_PACKAGE(SalomeOmniORBPy REQUIRED)
-ENDIF() 
+ENDIF()
 IF(SALOME_USE_MPI)
   FIND_PACKAGE(SalomeMPI REQUIRED)
   IF(HDF5_IS_PARALLEL)
@@ -105,10 +106,13 @@ ENDIF()
 IF(SALOME_PACO_PARALLEL)
   FIND_PACKAGE(SalomePaco REQUIRED)
 ENDIF()
+IF(SALOME_USE_PORTMANAGER)
+  ADD_DEFINITIONS(-DWITH_PORTMANAGER)
+ENDIF()
 IF(SALOME_BUILD_TESTS)
   ENABLE_TESTING()
   FIND_PACKAGE(SalomeCppUnit)
-  SALOME_LOG_OPTIONAL_PACKAGE(CppUnit SALOME_BUILD_TESTS)  
+  SALOME_LOG_OPTIONAL_PACKAGE(CppUnit SALOME_BUILD_TESTS)
 ENDIF()
 IF(SALOME_BUILD_DOC)
   FIND_PACKAGE(SalomeDoxygen)
@@ -131,27 +135,27 @@ SET(SALOME_INSTALL_BINS bin/salome CACHE PATH "Install path: SALOME binaries")
 SET(SALOME_INSTALL_LIBS lib/salome CACHE PATH "Install path: SALOME libs")
 SET(SALOME_INSTALL_IDLS idl/salome CACHE PATH "Install path: SALOME IDL files")
 SET(SALOME_INSTALL_HEADERS include/salome CACHE PATH "Install path: SALOME headers")
-SET(SALOME_INSTALL_SCRIPT_SCRIPTS ${SALOME_INSTALL_BINS} CACHE PATH 
+SET(SALOME_INSTALL_SCRIPT_SCRIPTS ${SALOME_INSTALL_BINS} CACHE PATH
    "Install path: SALOME scripts")
-SET(SALOME_INSTALL_SCRIPT_DATA ${SALOME_INSTALL_BINS} CACHE PATH 
+SET(SALOME_INSTALL_SCRIPT_DATA ${SALOME_INSTALL_BINS} CACHE PATH
    "Install path: SALOME script data")
-SET(SALOME_INSTALL_SCRIPT_PYTHON ${SALOME_INSTALL_BINS} CACHE PATH 
+SET(SALOME_INSTALL_SCRIPT_PYTHON ${SALOME_INSTALL_BINS} CACHE PATH
    "Install path: SALOME Python scripts")
-SET(SALOME_INSTALL_APPLISKEL_SCRIPTS ${SALOME_INSTALL_BINS}/appliskel CACHE PATH 
+SET(SALOME_INSTALL_APPLISKEL_SCRIPTS ${SALOME_INSTALL_BINS}/appliskel CACHE PATH
    "Install path: SALOME application skeleton - scripts")
-SET(SALOME_INSTALL_APPLISKEL_PYTHON ${SALOME_INSTALL_BINS}/appliskel CACHE PATH 
+SET(SALOME_INSTALL_APPLISKEL_PYTHON ${SALOME_INSTALL_BINS}/appliskel CACHE PATH
    "Install path: SALOME application skeleton - Python")
 SET(SALOME_INSTALL_CMAKE salome_adm/cmake_files CACHE PATH "Install path: SALOME CMake files")
-SET(SALOME_INSTALL_CMAKE_LOCAL adm_local/cmake_files CACHE PATH 
+SET(SALOME_INSTALL_CMAKE_LOCAL adm_local/cmake_files CACHE PATH
    "Install path: local SALOME CMake files")
-SET(SALOME_INSTALL_AMCONFIG salome_adm/unix CACHE PATH 
+SET(SALOME_INSTALL_AMCONFIG salome_adm/unix CACHE PATH
    "Install path: SALOME config files (obsolete, to be removed)")
-SET(SALOME_INSTALL_AMCONFIG_LOCAL adm_local/unix CACHE PATH 
+SET(SALOME_INSTALL_AMCONFIG_LOCAL adm_local/unix CACHE PATH
    "Install path: local SALOME config files (obsolete, to be removed)")
 
 SET(_pydir lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages)
 SET(SALOME_INSTALL_PYTHON ${_pydir}/salome CACHE PATH "Install path: SALOME Python stuff")
-SET(SALOME_INSTALL_PYTHON_SHARED ${SALOME_INSTALL_PYTHON}/shared_modules CACHE PATH 
+SET(SALOME_INSTALL_PYTHON_SHARED ${SALOME_INSTALL_PYTHON}/shared_modules CACHE PATH
    "Install path: SALOME Python shared modules")
 
 SET(SALOME_INSTALL_RES share/salome/resources CACHE PATH "Install path: SALOME resources")
@@ -174,7 +178,7 @@ SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOM
                                                  ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON_SHARED})
 SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_LIBS})
 
-# Sources 
+# Sources
 # ========
 IF(NOT SALOME_LIGHT_ONLY)
   ADD_SUBDIRECTORY(idl)
@@ -201,29 +205,29 @@ INCLUDE(CMakePackageConfigHelpers)
 
 # Temporary solution for package src\DSC on windows
 IF(NOT WIN32)
-  SET(DSC_TGS CalciumC SalomeCalcium SalomeDatastream 
+  SET(DSC_TGS CalciumC SalomeCalcium SalomeDatastream
   SalomePalm SalomeDSCSupervBasic SalomeDSCSuperv)
 ENDIF()
 
 SET(_${PROJECT_NAME}_exposed_targets
-  ${DSC_TGS} DF Launcher OpUtil Registry ResourcesManager 
-  SALOMEBasics SalomeCatalog SalomeCommunication SalomeContainer 
-  SalomeDSCContainer SalomeDSClient SalomeDSImpl 
+  ${DSC_TGS} DF Launcher OpUtil Registry ResourcesManager
+  SALOMEBasics SalomeCatalog SalomeCommunication SalomeContainer
+  SalomeDSCContainer SalomeDSClient SalomeDSImpl
   SalomeDS SalomeGenericObj SalomeHDFPersist SalomeIDLKernel
-  SalomeLauncher SalomeLifeCycleCORBA SALOMELocalTrace 
+  SalomeLauncher SalomeLifeCycleCORBA SALOMELocalTrace
   SalomeLoggerServer SalomeNotification SalomeNS
-  SalomeResourcesManager TOOLSDS with_loggerTraceCollector 
+  SalomeResourcesManager TOOLSDS with_loggerTraceCollector
   SalomeKernelHelpers)
-  
+
 # MPI specific targets:
 IF(SALOME_USE_MPI)
-  LIST(APPEND _${PROJECT_NAME}_exposed_targets 
+  LIST(APPEND _${PROJECT_NAME}_exposed_targets
        SalomeMPIContainer SalomeTestMPIComponentEngine)
 ENDIF()
 
 # Test targets:
 IF(SALOME_BUILD_TESTS)
-  LIST(APPEND _${PROJECT_NAME}_exposed_targets 
+  LIST(APPEND _${PROJECT_NAME}_exposed_targets
       LifeCycleCORBATest NamingServiceTest SALOMEDSImplTest SALOMEDSTest SALOMELocalTraceTest
       SalomeTestComponentEngine SALOMETraceCollectorTest UtilsTest )
 ENDIF()
@@ -249,10 +253,10 @@ SET(SIMANIO_ROOT_DIR "${SIMANIO_ROOT_DIR}")
 SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
 
 # Build variables that will be expanded when configuring Salome<MODULE>Config.cmake:
-SALOME_CONFIGURE_PREPARE(CppUnit Graphviz Doxygen Sphinx MPI omniORB LibBatch 
+SALOME_CONFIGURE_PREPARE(CppUnit Graphviz Doxygen Sphinx MPI omniORB LibBatch
                          PThread Boost HDF5 libXml2 Python SIMANIO HDF5)
 
-CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in 
+CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in
     ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
     INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE}"
     PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE CMAKE_INSTALL_PREFIX
@@ -262,13 +266,13 @@ CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in
        PYTHON_ROOT_DIR SWIG_ROOT_DIR)
 
 #   - in the install tree (VSR 16/08/2013: TEMPORARILY COMMENT THIS - TO REMOVE?):
-#       Get the relative path of the include directory so 
+#       Get the relative path of the include directory so
 #       we can register it in the generated configuration files:
 #SET(CONF_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR}")
-#CONFIGURE_PACKAGE_CONFIG_FILE(salome_adm/cmake_files/${PROJECT_NAME}Config.cmake.in 
+#CONFIGURE_PACKAGE_CONFIG_FILE(salome_adm/cmake_files/${PROJECT_NAME}Config.cmake.in
 #    ${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake
 #    INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE}"
-#    PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE CMAKE_INSTALL_PREFIX 
+#    PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE CMAKE_INSTALL_PREFIX
 #       CPPUNIT_ROOT_DIR GRAPHVIZ_ROOT_DIR DOXYGEN_ROOT_DIR
 #       SPHINX_ROOT_DIR MPI_ROOT_DIR OMNIORB_ROOT_DIR OMNIORBPY_ROOT_DIR LIBBATCH_ROOT_DIR
 #       SIMANIO_ROOT_DIR PTHREAD_ROOT_DIR BOOST_ROOT_DIR HDF5_ROOT_DIR LIBXML2_ROOT_DIR
@@ -277,7 +281,7 @@ CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in
 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
     VERSION ${${PROJECT_NAME_UC}_VERSION}
     COMPATIBILITY AnyNewerVersion)
-  
+
 # Install the CMake configuration files:
 INSTALL(FILES
   "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
@@ -285,5 +289,5 @@ INSTALL(FILES
   DESTINATION "${SALOME_INSTALL_CMAKE}")
 
 # Install the export set for use with the install-tree
-INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE}" 
+INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE}"
         FILE ${PROJECT_NAME}Targets.cmake)
index a5e884660c1e5392b490bb0fc6f93359565c947c..9f3908b148d7ca0ec71e0512944d7938256156c4 100644 (file)
@@ -1,5 +1,5 @@
 # - Config file for the @PROJECT_NAME@ package
-# It defines the following variables. 
+# It defines the following variables.
 # Specific to the pacakge @PROJECT_NAME@ itself:
 #  @PROJECT_NAME_UC@_ROOT_DIR_EXP - the root path of the installation providing this CMake file
 #
 ### Initialisation performed by CONFIGURE_PACKAGE_CONFIG_FILE:
 @PACKAGE_INIT@
 
-# Load the dependencies for the libraries of @PROJECT_NAME@ 
-# (contains definitions for IMPORTED targets). This is only 
+# Load the dependencies for the libraries of @PROJECT_NAME@
+# (contains definitions for IMPORTED targets). This is only
 # imported if we are not built as a subproject (in this case targets are already there)
 IF(NOT TARGET SALOMEBasics AND NOT @PROJECT_NAME@_BINARY_DIR)
   INCLUDE("@PACKAGE_SALOME_INSTALL_CMAKE@/@PROJECT_NAME@Targets.cmake")
-ENDIF()   
+ENDIF()
 
 # Package root dir:
 SET_AND_CHECK(KERNEL_ROOT_DIR_EXP "@PACKAGE_CMAKE_INSTALL_PREFIX@")
@@ -73,6 +73,11 @@ IF(SALOME_USE_SIMAN)
   LIST(APPEND KERNEL_DEFINITIONS "-DWITH_SIMANIO")
 ENDIF()
 
+SET(SALOME_USE_PORTMANAGER     @SALOME_USE_PORTMANAGER@)
+IF(SALOME_USE_PORTMANAGER)
+  LIST(APPEND KERNEL_DEFINITIONS "-DWITH_PORTMANAGER")
+ENDIF()
+
 # Prerequisites:
 IF(SALOME_KERNEL_BUILD_TESTS)
   SET_AND_CHECK(CPPUNIT_ROOT_DIR_EXP  "@PACKAGE_CPPUNIT_ROOT_DIR@")
@@ -102,7 +107,7 @@ SET_AND_CHECK(LIBXML2_ROOT_DIR_EXP  "@PACKAGE_LIBXML2_ROOT_DIR@")
 SET_AND_CHECK(PYTHON_ROOT_DIR_EXP   "@PACKAGE_PYTHON_ROOT_DIR@")
 SET_AND_CHECK(SWIG_ROOT_DIR_EXP     "@PACKAGE_SWIG_ROOT_DIR@")
 
-# For all prerequisites, load the corresponding targets if the package was used 
+# For all prerequisites, load the corresponding targets if the package was used
 # in CONFIG mode. This ensures dependent projects link correctly
 # without having to set LD_LIBRARY_PATH:
 SET(_PREREQ @_PREREQ_LIST@)
@@ -112,20 +117,20 @@ LIST(LENGTH _PREREQ_CONFIG_DIR _list_len)
 IF(NOT _list_len EQUAL 0)
   # Another CMake stupidity - FOREACH(... RANGE r) generates r+1 numbers ...
   MATH(EXPR _range "${_list_len}-1")
-  FOREACH(_p RANGE ${_range})  
+  FOREACH(_p RANGE ${_range})
     LIST(GET _PREREQ            ${_p} _pkg    )
     LIST(GET _PREREQ_CONFIG_DIR ${_p} _pkg_dir)
     LIST(GET _PREREQ_COMPONENTS ${_p} _pkg_compo)
     MESSAGE(STATUS "===> Reloading targets from ${_pkg} ...")
     IF(NOT _pkg_compo)
-      FIND_PACKAGE(${_pkg} REQUIRED NO_MODULE 
-          PATHS "${_pkg_dir}" 
+      FIND_PACKAGE(${_pkg} REQUIRED NO_MODULE
+          PATHS "${_pkg_dir}"
           NO_DEFAULT_PATH)
     ELSE()
       STRING(REPLACE "," ";" _compo_lst "${_pkg_compo}")
       MESSAGE(STATUS "===> (components: ${_pkg_compo})")
       FIND_PACKAGE(${_pkg} REQUIRED NO_MODULE
-          COMPONENTS ${_compo_lst} 
+          COMPONENTS ${_compo_lst}
           PATHS "${_pkg_dir}"
           NO_DEFAULT_PATH)
     ENDIF()
@@ -141,7 +146,7 @@ SET(SALOME_INSTALL_SCRIPT_SCRIPTS "@SALOME_INSTALL_SCRIPT_SCRIPTS@")
 SET(SALOME_INSTALL_SCRIPT_DATA "@SALOME_INSTALL_SCRIPT_DATA@")
 SET(SALOME_INSTALL_SCRIPT_PYTHON "@SALOME_INSTALL_SCRIPT_PYTHON@")
 SET(SALOME_INSTALL_APPLISKEL_SCRIPTS "@SALOME_INSTALL_APPLISKEL_SCRIPTS@")
-SET(SALOME_INSTALL_APPLISKEL_PYTHON "@SALOME_INSTALL_APPLISKEL_PYTHON@") 
+SET(SALOME_INSTALL_APPLISKEL_PYTHON "@SALOME_INSTALL_APPLISKEL_PYTHON@")
 SET(SALOME_INSTALL_CMAKE "@SALOME_INSTALL_CMAKE@")
 SET(SALOME_INSTALL_CMAKE_LOCAL "@SALOME_INSTALL_CMAKE_LOCAL@")
 SET(SALOME_INSTALL_PYTHON "@SALOME_INSTALL_PYTHON@")
index 07ef256a4123270d0ff4525fc8b0d8a5ba700086..b2847db74e8470a76c9feadad9a82fab0e6b0724 100755 (executable)
@@ -43,7 +43,6 @@ SET(SCRIPTS
   orbmodule.py
   ORBConfigFile.py
   parseConfigFile.py
-  PortManager.py
   runSalome
   runSalome.py
   runSession.py
@@ -58,9 +57,17 @@ SET(SCRIPTS
   setenv.py
   showNS.py
   shutdownSalome.py
-  Singleton.py
   virtual_salome.py
   waitContainers.py
   waitNS.py
   )
+
+IF(SALOME_USE_PORTMANAGER)
+  SET(PORTMANAGER_SCRIPTS
+    PortManager.py
+    Singleton.py
+    )
+  LIST(APPEND SCRIPTS ${PORTMANAGER_SCRIPTS})
+ENDIF()
+
 SALOME_INSTALL_SCRIPTS("${SCRIPTS}" ${SALOME_INSTALL_SCRIPT_SCRIPTS})
index a919ee7c583b34e739d8b95fe3b1a332a9303b11..da1e06cd6732fa1c9e5ab4d12004e96512feae66 100644 (file)
@@ -175,13 +175,13 @@ class _ThreadedTCPRequestHandler(SocketServer.BaseRequestHandler):
       pm.releasePort(port)
       response = "%s" % (RELEASE_PORT_ACK_MSG)
       _send(self.request, response)
-      print "RELEASE_PORT:", port
+      #print "RELEASE_PORT:", port
       if not pm.isBusy():
-        print "Close server"
+        #print "Close server"
         self.server.shutdown()
       #print pm
     elif data == STOP_SERVER_MSG:
-      print "Close server"
+      #print "Close server"
       self.server.shutdown()
 #
 
@@ -211,10 +211,10 @@ def __startServer():
     #server_thread.setDaemon(True)
     server_thread.start()
     #print "Server loop running in thread:", server_thread.getName()
-    print "Server address:", pm_address
+    #print "Server address:", pm_address
     #return address
   except:
-    print "Server already started"
+    #print "Server already started"
     #print "Server address:", pm_address
     #return pm_address
     pass
@@ -229,7 +229,7 @@ def __newClient(address, message):
     response = _receive(sock)
     if response.startswith(GET_PORT_ACK_MSG):
       port = int(response[len(GET_PORT_ACK_MSG)+1:])
-      print "GET_PORT:", port
+      #print "GET_PORT:", port
       return port
     elif response == RELEASE_PORT_ACK_MSG:
       #print "Received: %s" % response
@@ -237,7 +237,7 @@ def __newClient(address, message):
       pass
     sock.close()
   except socket.error:
-    print "Unable to connect to server"
+    #print "Unable to connect to server"
     return -1
 #
 
index 2e2bf65c874c9410b6950e3b008bf315a5a84698..71dd451736d1ac088a003ae7f0a211eff0868b5c 100755 (executable)
@@ -141,8 +141,11 @@ def shutdownMyPort(port, cleanup=True):
     """
     if not port: return
 
-    from PortManager import releasePort
-    releasePort(port)
+    try:
+        from PortManager import releasePort
+        releasePort(port)
+    except ImportError:
+        pass
 
     from salome_utils import generateFileName
 
@@ -189,8 +192,11 @@ def killMyPort(port):
     Parameters:
     - port - port number
     """
-    import PortManager
-    PortManager.releasePort(port)
+    try:
+        import PortManager
+        PortManager.releasePort(port)
+    except ImportError:
+        pass
 
     from salome_utils import getShortHostName, getHostName
 
index 9c749791577a332f78416507bbf378ab5f29433a..0fb63c0d21f9c4162e211c8dcf75a6d29486e765 100755 (executable)
@@ -923,8 +923,13 @@ def get_env(theAdditionalOptions=[], appname=salomeappname, cfgname=salomecfgnam
         from searchFreePort import searchFreePort
         searchFreePort({})
         print "port:%s"%(os.environ['NSPORT'])
-        import PortManager
-        PortManager.releasePort(os.environ['NSPORT'])
+
+        try:
+            import PortManager
+            PortManager.releasePort(os.environ['NSPORT'])
+        except ImportError:
+            pass
+
         sys.exit(0)
         pass
 
index bda4863c023384154cd89ec259697d4b4eb93498..83e52873453451133abbe2a643dcc7f6344e4af3 100644 (file)
@@ -45,7 +45,7 @@ def __setup_config(nsport, args, save_config):
                                            extension="cfg",
                                            hidden=True,
                                            **kwargs)
-    #os.environ['LAST_RUNNING_CONFIG'] = last_running_config
+    os.environ['LAST_RUNNING_CONFIG'] = last_running_config
     try:
       if sys.platform == "win32":
         import shutil
@@ -64,12 +64,66 @@ def __setup_config(nsport, args, save_config):
   #
 #
 
-def searchFreePort(args={}, save_config=1, use_port=None):
-  """
-  Search free port for SALOME session.
-  Returns first found free port number.
-  """
+def searchFreePort_withoutPortManager(args={}, save_config=1, use_port=None):
+  # :NOTE: Under windows:
+  #        netstat options -l and -t are unavailable
+  #        grep command is unavailable
+  from subprocess import Popen, PIPE
+  (stdout, stderr) = Popen(['netstat','-an'], stdout=PIPE).communicate()
+  import StringIO
+  buf = StringIO.StringIO(stdout)
+  ports = buf.readlines()
+
+  #
+  def portIsUsed(port, data):
+    import re
+    regObj = re.compile( ".*tcp.*:([0-9]+).*:.*listen", re.IGNORECASE );
+    for item in data:
+      try:
+        p = int(regObj.match(item).group(1))
+        if p == port: return True
+        pass
+      except:
+        pass
+      pass
+    return False
+  #
 
+  if use_port:
+    print "Check if port can be used: %d" % use_port,
+    if not portIsUsed(use_port, ports):
+      print "- OK"
+      __setup_config(use_port, args, save_config)
+      return
+    else:
+      print "- KO: port is busy"
+    pass
+  #
+
+  print "Searching for a free port for naming service:",
+  #
+
+  NSPORT=2810
+  limit=NSPORT+100
+  #
+
+  while 1:
+    if not portIsUsed(NSPORT, ports):
+      print "%s - OK"%(NSPORT)
+      __setup_config(NSPORT, args, save_config)
+      break
+    print "%s"%(NSPORT),
+    if NSPORT == limit:
+      msg  = "\n"
+      msg += "Can't find a free port to launch omniNames\n"
+      msg += "Try to kill the running servers and then launch SALOME again.\n"
+      raise RuntimeError, msg
+    NSPORT=NSPORT+1
+    pass
+  #
+#
+
+def searchFreePort_withPortManager(args={}, save_config=1, use_port=None):
   from PortManager import getPort
   port = getPort(use_port)
 
@@ -93,3 +147,15 @@ def searchFreePort(args={}, save_config=1, use_port=None):
   else:
     print "Unable to obtain port"
 #
+
+def searchFreePort(args={}, save_config=1, use_port=None):
+  """
+  Search free port for SALOME session.
+  Returns first found free port number.
+  """
+  try:
+    import PortManager
+    searchFreePort_withPortManager(args, save_config, use_port)
+  except ImportError:
+    searchFreePort_withoutPortManager(args, save_config, use_port)
+#
index 01368dd60efb4ec06d6675aa165237922965fd6c..13634f4984e69ef0713bcc48449f992f47bff8d9 100644 (file)
@@ -621,6 +621,7 @@ void SALOME_LifeCycleCORBA::killOmniNames()
     system( cmd.c_str() );
   }
 
+#ifdef WITH_PORTMANAGER
   // shutdown portmanager
   if ( !portNumber.empty() )
   {
@@ -630,6 +631,7 @@ void SALOME_LifeCycleCORBA::killOmniNames()
     MESSAGE(cmd);
     system( cmd.c_str() );
   }
+#endif
 }
 
 //=============================================================================