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
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)
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)
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")
${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)
# 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()
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
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
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"
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)
# - 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@")
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@")
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@)
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()
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@")
orbmodule.py
ORBConfigFile.py
parseConfigFile.py
- PortManager.py
runSalome
runSalome.py
runSession.py
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})
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()
#
#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
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
pass
sock.close()
except socket.error:
- print "Unable to connect to server"
+ #print "Unable to connect to server"
return -1
#
"""
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
Parameters:
- port - port number
"""
- import PortManager
- PortManager.releasePort(port)
+ try:
+ import PortManager
+ PortManager.releasePort(port)
+ except ImportError:
+ pass
from salome_utils import getShortHostName, getHostName
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
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
#
#
-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)
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)
+#
system( cmd.c_str() );
}
+#ifdef WITH_PORTMANAGER
// shutdown portmanager
if ( !portNumber.empty() )
{
MESSAGE(cmd);
system( cmd.c_str() );
}
+#endif
}
//=============================================================================