From: barate Date: Mon, 6 Feb 2012 10:20:59 +0000 (+0000) Subject: Merge from V6_main X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0bf92898aada869831ebcd17784c565e1233c587;p=modules%2Fkernel.git Merge from V6_main --- diff --git a/bin/launchConfigureParser.py b/bin/launchConfigureParser.py index caf138cd1..f273e7364 100755 --- a/bin/launchConfigureParser.py +++ b/bin/launchConfigureParser.py @@ -746,13 +746,14 @@ def CreateOptionParser (theAdditionalOptions=[]): dest="wake_up_session", default=False, help=help_str) - # Launch server processes with a specific command. Default: False. - help_str = "Launch server processes with a specific command." - o_slc = optparse.Option("--server-launch-cmd", - metavar="", - type="string", + # server launch mode + help_str = "Mode used to launch server processes (daemon or fork)." + o_slm = optparse.Option("--server-launch-mode", + metavar="", + type="choice", + choices=["daemon","fork"], action="store", - dest="server_launch_cmd", + dest="server_launch_mode", help=help_str) # All options @@ -783,7 +784,7 @@ def CreateOptionParser (theAdditionalOptions=[]): o_shutdown, o_foreground, o_wake_up, - o_slc, # Server launch command + o_slm, # Server launch mode ] #std_options = ["gui", "desktop", "log_file", "py_scripts", "resources", @@ -1133,8 +1134,8 @@ def get_env(theAdditionalOptions=[], appname=salomeappname, cfgname=salomecfgnam args[play_nam] += re.split( "[:;,]", filename ) # Server launch command - if cmd_opts.server_launch_cmd is not None: - args["server_launch_cmd"] = cmd_opts.server_launch_cmd + if cmd_opts.server_launch_mode is not None: + args["server_launch_mode"] = cmd_opts.server_launch_mode # return arguments os.environ[config_var] = separator.join(dirs) diff --git a/bin/runSalome.py b/bin/runSalome.py index 5dd6137c6..9f52819db 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -418,8 +418,8 @@ def startSalome(args, modules_list, modules_root_dir): # # Set server launch command # - if args.has_key('server_launch_cmd'): - Server.set_server_launch_cmd(args['server_launch_cmd']) + if args.has_key('server_launch_mode'): + Server.set_server_launch_mode(args['server_launch_mode']) # # Wake up session option diff --git a/bin/server.py b/bin/server.py index 3fde06b40..1f6d95c44 100755 --- a/bin/server.py +++ b/bin/server.py @@ -34,7 +34,7 @@ process_id = {} class Server: """Generic class for CORBA server launch""" - server_launch_args = [] + server_launch_mode = "daemon" def initArgs(self): self.PID=None @@ -51,12 +51,11 @@ class Server: self.initArgs() @staticmethod - def set_server_launch_cmd(cmd): - if cmd == "srun": - Server.server_launch_args = ["srun", "-n", "1", "-N", "1"] - Server.server_launch_args += ["--share", "--nodelist=%s" % getHostName()] - else: - print >>sys.stderr, "Unknown server launch command:%s" % cmd + def set_server_launch_mode(mode): + if mode == "daemon" or mode == "fork": + Server.server_launch_mode = mode + else: + raise Exception("Unsupported server launch mode: %s" % mode) def run(self): global process_id @@ -76,8 +75,9 @@ class Server: #pid = win32pm.spawnpid( cmd_str ) pid = win32pm.spawnpid( string.join(command, " "), '-nc' ) #pid = win32pm.spawnpid( string.join(command, " ") ) - else: - #pid = os.spawnvp(os.P_NOWAIT, command[0], command) + elif Server.server_launch_mode == "fork": + pid = os.spawnvp(os.P_NOWAIT, command[0], command) + else: # Server launch mode is daemon pid=self.daemonize(command) if pid is not None: #store process pid if it really exists @@ -134,9 +134,8 @@ class Server: #I am a daemon os.close(0) #close stdin os.open("/dev/null", os.O_RDWR) # redirect standard input (0) to /dev/null - all_args = Server.server_launch_args + args try: - os.execvp(all_args[0], all_args) + os.execvp(args[0], args) except OSError, e: if args[0] != "notifd": print >>sys.stderr, "(%s) launch failed: %d (%s)" % (args[0],e.errno, e.strerror) diff --git a/salome_adm/cmake_files/FindSPHINX.cmake b/salome_adm/cmake_files/FindSPHINX.cmake new file mode 100755 index 000000000..b11663161 --- /dev/null +++ b/salome_adm/cmake_files/FindSPHINX.cmake @@ -0,0 +1,98 @@ +# Copyright (C) 2007-2011 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 +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +# ------ +MESSAGE(STATUS "Check for sphinx ...") +# ------ + +IF(SPHINX_IS_MANDATORY STREQUAL 0) + SET(SPHINX_IS_MANDATORY 0) + SET(SPHINX_IS_OPTIONAL 1) +ENDIF(SPHINX_IS_MANDATORY STREQUAL 0) +IF(SPHINX_IS_OPTIONAL STREQUAL 0) + SET(SPHINX_IS_MANDATORY 1) + SET(SPHINX_IS_OPTIONAL 0) +ENDIF(SPHINX_IS_OPTIONAL STREQUAL 0) +IF(NOT SPHINX_IS_MANDATORY AND NOT SPHINX_IS_OPTIONAL) + SET(SPHINX_IS_MANDATORY 0) + SET(SPHINX_IS_OPTIONAL 1) +ENDIF(NOT SPHINX_IS_MANDATORY AND NOT SPHINX_IS_OPTIONAL) + +# ------ + +SET(SPHINX_STATUS 1) +IF(WITHOUT_SPHINX OR WITH_SPHINX STREQUAL 0) + SET(SPHINX_STATUS 0) + MESSAGE(STATUS "sphinx disabled from command line.") +ENDIF(WITHOUT_SPHINX OR WITH_SPHINX STREQUAL 0) + +# ------ + +IF(SPHINX_STATUS) + IF(WITH_SPHINX) + SET(SPHINX_ROOT_USER ${WITH_SPHINX}) + ENDIF(WITH_SPHINX) + IF(NOT SPHINX_ROOT_USER) + SET(SPHINX_ROOT_USER $ENV{SPHINX_ROOT}) + ENDIF(NOT SPHINX_ROOT_USER) + IF(NOT SPHINX_ROOT_USER) + SET(SPHINX_ROOT_USER $ENV{SPHINXHOME}) + ENDIF(NOT SPHINX_ROOT_USER) +ENDIF(SPHINX_STATUS) + +# ------ + +IF(SPHINX_STATUS) + SET(SPHINX_EXECUTABLE_TO_FIND sphinx-build) + IF(SPHINX_ROOT_USER) + SET(BINDIR) + IF(WINDOWS) + SET(BINDIR ${SPHINX_ROOT_USER}/Scripts) + ELSE(WINDOWS) + SET(BINDIR ${SPHINX_ROOT_USER}/bin) + ENDIF(WINDOWS) + FIND_PROGRAM(SPHINX_EXECUTABLE ${SPHINX_EXECUTABLE_TO_FIND} PATHS ${BINDIR} NO_DEFAULT_PATH) + ELSE(SPHINX_ROOT_USER) + FIND_PROGRAM(SPHINX_EXECUTABLE ${SPHINX_EXECUTABLE_TO_FIND}) + ENDIF(SPHINX_ROOT_USER) + IF(SPHINX_EXECUTABLE) + MESSAGE(STATUS "${SPHINX_EXECUTABLE_TO_FIND} found: ${SPHINX_EXECUTABLE}") + ELSE(SPHINX_EXECUTABLE) + MESSAGE(STATUS "${SPHINX_EXECUTABLE_TO_FIND} not found, try to use WITH_SPHINX option or SPHINX_ROOT (or SPHINXHOME) environment variable") + SET(SPHINX_STATUS 0) + ENDIF(SPHINX_EXECUTABLE) +ENDIF(SPHINX_STATUS) + +# ---- + +IF(SPHINX_STATUS) + SET(SPHINX_IS_OK 1) +ELSE(SPHINX_STATUS) + SET(SPHINX_IS_OK 0) + IF(SPHINX_IS_MANDATORY) + MESSAGE(FATAL_ERROR "sphinx not found ... mandatory ... abort") + ELSE(SPHINX_IS_MANDATORY) + MESSAGE(STATUS "sphinx not found ... optional ... disabled") + ENDIF(SPHINX_IS_MANDATORY) +ENDIF(SPHINX_STATUS) + +# ---- diff --git a/salome_adm/cmake_files/Makefile.am b/salome_adm/cmake_files/Makefile.am index 4d2ef90bb..50d715e45 100644 --- a/salome_adm/cmake_files/Makefile.am +++ b/salome_adm/cmake_files/Makefile.am @@ -38,5 +38,8 @@ FindPLATFORM.cmake \ FindPTHREADS.cmake \ FindPYTHON.cmake \ FindSWIG.cmake \ +FindSPHINX.cmake \ install_python_from_idl.cmake \ install_and_compile_python_file.cmake + +bin_SCRIPTS = prepare_generating_doc.py diff --git a/salome_adm/cmake_files/am2cmake.py b/salome_adm/cmake_files/am2cmake.py index b93e4bfaf..8c1da8114 100644 --- a/salome_adm/cmake_files/am2cmake.py +++ b/salome_adm/cmake_files/am2cmake.py @@ -286,6 +286,8 @@ class CMakeFile(object): "ToolsGUI", "ViewerTools", "VTKViewer", + "vtkEDFOverloads", + "vtkTools" ] geom_list = [ "AdvancedGUI", @@ -316,6 +318,7 @@ class CMakeFile(object): "IGESExport", "IGESImport", "MeasureGUI", + "Material", "NMTDS", "NMTTools", "OCC2VTK", @@ -394,6 +397,7 @@ class CMakeFile(object): # -- for key in full_list: content = content.replace("-l%s"%(key), "${%s}"%(key)) + pass # -- @@ -493,6 +497,7 @@ class CMakeFile(object): INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindDOXYGEN.cmake) INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindMPI.cmake) INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindLIBBATCH.cmake) + INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindSPHINX.cmake) """) pass else: @@ -573,8 +578,15 @@ class CMakeFile(object): INCLUDE(${GEOM_ROOT_DIR}/adm_local/cmake_files/FindGEOM.cmake) INCLUDE(${MED_ROOT_DIR}/adm_local/cmake_files/FindMEDFILE.cmake) INCLUDE(${MED_ROOT_DIR}/adm_local/cmake_files/FindMED.cmake) + INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindSPHINX.cmake) """) pass + if self.module == "geom": + newlines.append(""" + INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindSPHINX.cmake) + """) + pass + if self.module == "netgenplugin": newlines.append(""" SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR}) @@ -628,6 +640,7 @@ class CMakeFile(object): newlines.append(""" INCLUDE(${CMAKE_SOURCE_DIR}/adm/cmake/FindEXPAT.cmake) INCLUDE(${CMAKE_SOURCE_DIR}/adm/cmake/FindGRAPHVIZ.cmake) + INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindSPHINX.cmake) """) pass if self.module == "hxx2salome": @@ -772,6 +785,7 @@ class CMakeFile(object): # -- newlines.append(""" set(VERSION 6.4.0) + set(SHORT_VERSION 6.4) set(XVERSION 0x060400) """) pass @@ -1021,13 +1035,6 @@ class CMakeFile(object): # -- fields = value.split() - - #rnv: Temporary solution for windows platform: - #rnv: To remove GUI_SRC/tools directory, because it contains shell scripts - #rnv: Will be fixed in the future - from sys import platform - if platform == "win32" and self.module == 'gui' and self.root[-len('GUI_SRC'):] == 'GUI_SRC' and key.endswith("SUBDIRS"): - fields.remove("tools") for i in range(len(fields)): newlines.append("%s %s"%(spaces, fields[i])) @@ -1120,6 +1127,14 @@ class CMakeFile(object): self.files.append("resources/SalomeApp.xml.in") pass pass + from os import path + if operator.contains(self.root, 'YACS_SRC'+path.sep+'doc'): + newlines.append(r''' + SET(srcdir + ${CMAKE_CURRENT_SOURCE_DIR} + ) + ''') + if self.module == "jobmanager": key = "salomegui" if self.root[-len(key):] == key: @@ -1185,7 +1200,7 @@ class CMakeFile(object): VERBATIM WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} )"""%(input, copytree_src, doc_gui_destination, doc_source, doc_gui_destination, head_source, doc_gui_destination)) - + from os import path if mod in ['geom', 'smesh', 'visu'] and self.root[-len(mod):] == upmod and operator.contains(self.root, 'doc'): ign = r"""'tempfile', '*usr_docs*', '*CMakeFiles*', '*.cmake', 'doxyfile*', '*.vcproj', 'static', 'Makefile*'""" if mod in ['geom', 'smesh']: @@ -1212,6 +1227,42 @@ class CMakeFile(object): VERBATIM WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} )"""%(copytree_src, doc_gui_destination, doc_gui_destination, ign, head_source, doc_gui_destination)) + elif mod == 'yacs' and operator.contains(self.root, upmod + '_SRC'+path.sep+'doc'): + from sys import platform + params = ''; + if platform == "win32": + params = '-Q'; + newlines.append(r""" + ADD_CUSTOM_TARGET(html_docs ${SPHINX_EXECUTABLE} %s -c ${CMAKE_BINARY_DIR}/doc -b html ${ALLSPHINXOPTS} html + COMMAND ${PYTHON_EXECUTABLE} -c \"import shutil\;shutil.rmtree('''%s''', True)\;shutil.copytree('''${CMAKE_CURRENT_BINARY_DIR}/html''', '''%s''')\" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})"""%(params, doc_gui_destination, doc_gui_destination)) + elif mod in ['kernel', 'smesh', 'geom'] and operator.contains(self.root, upmod + '_SRC'+path.sep+'doc'+path.sep+'docutils'): + from sys import platform + params = "" + ext = "" + prf = "" + if platform == "win32": + params = '-Q'; + ext = "bat" + prf = "call" + else: + ext = "sh" + prf = ". " + doc_gui_destination = "${CMAKE_INSTALL_PREFIX}/share/doc/salome/tui/%s/docutils"%(upmod) + scr = self.writeEnvScript(upmod) + newlines.append(r""" + IF(WINDOWS) + STRING(REPLACE "/" "\\" SCR "%s") + ELSE(WINDOWS) + SET(SCR "%s") + ENDIF(WINDOWS) + FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/env_s.%s "${SCR}") + ADD_CUSTOM_TARGET(html_docs %s ${CMAKE_CURRENT_BINARY_DIR}/env_s.%s && ${SPHINX_EXECUTABLE} %s -c ${CMAKE_BINARY_DIR}/doc/docutils -W -b html ${ALLSPHINXOPTS} html + COMMAND ${PYTHON_EXECUTABLE} -c \"import shutil\;shutil.rmtree('''%s''', True)\;shutil.copytree('''${CMAKE_CURRENT_BINARY_DIR}/html''', '''%s''')\" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})"""%(scr,scr,ext,prf,ext,params, doc_gui_destination, doc_gui_destination)) + + + # -- # add commands for generating of developer's documentation @@ -1268,7 +1319,7 @@ class CMakeFile(object): # -- # -- - for key in ["lib_LTLIBRARIES", "noinst_LTLIBRARIES", "salomepyexec_LTLIBRARIES"]: + for key in ["lib_LTLIBRARIES", "noinst_LTLIBRARIES", "salomepyexec_LTLIBRARIES", "libparaview_LTLIBRARIES"] : if self.__thedict__.has_key(key): self.addLibTarget(key, newlines) pass @@ -1596,14 +1647,14 @@ class CMakeFile(object): ADD_CUSTOM_COMMAND( OUTPUT QDialogTest.ui QDialogTest.hxx QDialogTest.cxx - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/dlgfactory.sh -n QDialogTest -t qdialog - DEPENDS __QDIALOG__.ui __QDIALOG__.hxx __QDIALOG__.cxx dlgfactory.sh + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/dlgfactory.py -n QDialogTest -t qdialog + DEPENDS __QDIALOG__.ui __QDIALOG__.hxx __QDIALOG__.cxx dlgfactory.py ) ADD_CUSTOM_COMMAND( OUTPUT GDialogTest.ui GDialogTest.hxx GDialogTest.cxx - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/dlgfactory.sh -n GDialogTest -t gdialog - DEPENDS __GDIALOG__.ui __GDIALOG__.hxx __GDIALOG__.cxx dlgfactory.sh + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/dlgfactory.py -n GDialogTest -t gdialog + DEPENDS __GDIALOG__.ui __GDIALOG__.hxx __GDIALOG__.cxx dlgfactory.py ) ''') pass @@ -2092,6 +2143,10 @@ class CMakeFile(object): newlines.append(r''' SET(DEST lib) ''') + elif key == "libparaview_LTLIBRARIES": + newlines.append(r''' + SET(DEST lib/paraview) + ''') else: newlines.append(r''' SET(DEST lib/salome) @@ -2365,7 +2420,72 @@ class CMakeFile(object): f.write(self.content) f.close() return - + + def writeEnvScript(self, upmod): + from sys import platform, version_info + p_version = """%s.%s"""%(version_info[0],version_info[1]) + python_path ="PYTHONPATH" + path = "" + begin = "" + end = "" + delim = "" + cmd = "" + pdir = "" + omni = "" + omni_py = "" + if platform == "win32" : + path = "PATH" + begin = "%" + end = "%" + delim = ";" + cmd = "@SET " + omni = "/x86_win32" + omni_py = "/python" + pdir = "PDIR" + else: + path = "LD_LIBRARY_PATH" + begin = "\${" + end = "}" + delim = ":" + cmd = "export " + omni_py = "/python" + p_version + "/" + "site-packages" + pdir = "INST_ROOT" + + + path_ = begin + path + end + root_dir_ = begin + upmod + "_ROOT_DIR" + end + python_path_ = begin + python_path + end + _python_path_ = delim + python_path_+ "\n" + _path_ = delim + path_+ "\n" + _pdir = begin + pdir + end + + + script = cmd + " " + python_path + "=" + root_dir_+"/lib/python" + p_version \ + + "/site-packages/salome" + _python_path_ + + script = script + cmd + " " + python_path + "=" + root_dir_+"/bin/salome" + \ + _python_path_ + + script = script + cmd + " "+ path + "=" + root_dir_+"/lib/salome"+ _path_ + + if upmod == "KERNEL" : + script = script + cmd + " " + python_path + "=" + _pdir + \ + "/omniORB-4.1.5/lib" + omni + _python_path_ + + script = script + cmd + " " + python_path + "=" + _pdir + \ + "/omniORB-4.1.5/lib" + omni_py + _python_path_ + + script = script + cmd + " "+ path + "=" + _pdir+ "/omniORB-4.1.5/lib" + \ + omni + _path_ + + if upmod == "GEOM" : + script = self.writeEnvScript("KERNEL") + script + script = self.writeEnvScript("GUI") + script + + if upmod == "SMESH" : + script = self.writeEnvScript("GEOM") + script + + return script pass def convertAmFile(the_root, root, dirs, files, f, module): diff --git a/salome_adm/cmake_files/prepare_generating_doc.py b/salome_adm/cmake_files/prepare_generating_doc.py new file mode 100755 index 000000000..5992979f3 --- /dev/null +++ b/salome_adm/cmake_files/prepare_generating_doc.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python + +import sys, re +outfile = open(sys.argv[1], 'wb') +isCom = False +for line in open(sys.argv[2], 'rb').readlines(): + if re.match('class '+sys.argv[3]+'DC', line): + continue + n = line.find('"""') + n1 = line[(n+2):].find('"""') + if (n > -1) and (n1 > -1): + continue + if isCom: + if n > -1: + isCom = False + continue + else: + if n > -1: + isCom = True + continue + line = re.sub(r'^\s+#', '#', line) + line = re.sub(r'^\s+def', 'def', line) + line = re.sub(sys.argv[3]+'DC', sys.argv[3], line) + outfile.write(line) +outfile.close() \ No newline at end of file diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index 8ad253294..f8fde3759 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -444,10 +444,10 @@ SALOME_ContainerManager::GiveContainer(const Engines::ContainerParameters& param std::string command; // if a parallel container is launched in batch job, command is: "mpirun -np nbproc -machinefile nodesfile SALOME_MPIContainer" if( getenv("LIBBATCH_NODEFILE") != NULL && params.isMPI ) - command = BuildCommandToLaunchLocalContainer(resource_selected, params, machFile, container_exe); + command = BuildCommandToLaunchLocalContainer(params, machFile, container_exe); // if a container is launched on localhost, command is "SALOME_Container" or "mpirun -np nbproc SALOME_MPIContainer" else if(hostname == Kernel_Utils::GetHostname()) - command = BuildCommandToLaunchLocalContainer(resource_selected, params, machFile, container_exe); + command = BuildCommandToLaunchLocalContainer(params, machFile, container_exe); // if a container is launched in remote mode, command is "ssh resource_selected SALOME_Container" or "ssh resource_selected mpirun -np nbproc SALOME_MPIContainer" else command = BuildCommandToLaunchRemoteContainer(resource_selected, params, container_exe); @@ -652,7 +652,7 @@ SALOME_ContainerManager::BuildCommandToLaunchRemoteContainer // "ssh -l user machine distantPath/runRemote.sh hostNS portNS WORKINGDIR workingdir \ // SALOME_Container containerName &" - command = getCommandToRunProcess(resInfo.Protocol, resInfo.HostName, resInfo.UserName); + command = getCommandToRunRemoteProcess(resInfo.Protocol, resInfo.HostName, resInfo.UserName); if (resInfo.AppliPath != "") command += resInfo.AppliPath; // path relative to user@machine $HOME @@ -722,7 +722,7 @@ SALOME_ContainerManager::BuildCommandToLaunchRemoteContainer //============================================================================= std::string SALOME_ContainerManager::BuildCommandToLaunchLocalContainer -(const std::string & resource_name, const Engines::ContainerParameters& params, const std::string& machinesFile, const std::string& container_exe) +(const Engines::ContainerParameters& params, const std::string& machinesFile, const std::string& container_exe) { _TmpFileName = BuildTemporaryFileName(); std::string command; @@ -793,9 +793,6 @@ SALOME_ContainerManager::BuildCommandToLaunchLocalContainer } } - const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesDescr(resource_name); - o << getCommandToRunProcess(resInfo.Protocol); - if (isPythonContainer(params.container_name)) o << "SALOME_ContainerPy.py "; else @@ -1167,48 +1164,39 @@ std::set SALOME_ContainerManager::getpidofprogram(const std::string progr return thepids; } -std::string SALOME_ContainerManager::getCommandToRunProcess(AccessProtocolType protocol, - const std::string & hostname, - const std::string & username) +std::string SALOME_ContainerManager::getCommandToRunRemoteProcess(AccessProtocolType protocol, + const std::string & hostname, + const std::string & username) { - std::string hostRealName = hostname; - std::string localHostRealName = Kernel_Utils::GetHostname(); - bool isLocal = false; - if (hostname == "localhost" || hostname == localHostRealName) - { - isLocal = true; - hostRealName = localHostRealName; - } - std::ostringstream command; switch (protocol) { case rsh: - if (!isLocal) + command << "rsh "; + if (username != "") { - command << "rsh "; - if (username != "") - { - command << "-l " << username << " "; - } - command << hostRealName << " "; + command << "-l " << username << " "; } + command << hostname << " "; break; case ssh: - if (!isLocal) + command << "ssh "; + if (username != "") { - command << "ssh "; - if (username != "") - { - command << "-l " << username << " "; - } - command << hostRealName << " "; + command << "-l " << username << " "; } + command << hostname << " "; break; case srun: // no need to redefine the user with srun, the job user is taken by default // (note: for srun, user id can be specified with " --uid=") - command << "srun -n 1 -N 1 --share --nodelist=" << hostRealName << " "; + command << "srun -n 1 -N 1 --share --nodelist=" << hostname << " "; + break; + case pbsdsh: + command << "pbsdsh -o -h " << hostname << " "; + break; + case blaunch: + command << "blaunch " << hostname << " "; break; default: throw SALOME_Exception("Unknown protocol"); diff --git a/src/Container/SALOME_ContainerManager.hxx b/src/Container/SALOME_ContainerManager.hxx index 3aa218c2a..ef5729d20 100644 --- a/src/Container/SALOME_ContainerManager.hxx +++ b/src/Container/SALOME_ContainerManager.hxx @@ -69,8 +69,7 @@ protected: const Engines::ContainerParameters& params, const std::string& container_exe="SALOME_Container"); - std::string BuildCommandToLaunchLocalContainer(const std::string & resource_name, - const Engines::ContainerParameters& params, + std::string BuildCommandToLaunchLocalContainer(const Engines::ContainerParameters& params, const std::string& machinesFile, const std::string& container_exe="SALOME_Container"); @@ -93,9 +92,9 @@ protected: std::set getpidofprogram(const std::string program); - std::string getCommandToRunProcess(AccessProtocolType protocol, - const std::string & hostname = "localhost", - const std::string & username = ""); + std::string getCommandToRunRemoteProcess(AccessProtocolType protocol, + const std::string & hostname, + const std::string & username); CORBA::ORB_var _orb; PortableServer::POA_var _poa; diff --git a/src/Container/SALOME_ContainerPy.py b/src/Container/SALOME_ContainerPy.py index ffdc6b08f..a51ddc418 100755 --- a/src/Container/SALOME_ContainerPy.py +++ b/src/Container/SALOME_ContainerPy.py @@ -168,17 +168,24 @@ class SALOME_ContainerPy_i (Engines__POA.Container): def import_component(self, componentName): MESSAGE( "SALOME_Container_i::import_component" ) - ret=0 + reason = "" try: - if verbose(): print "try import ",componentName + if verbose(): print "try import %s" % componentName + # try import component module=__import__(componentName) - if verbose(): print "import ",componentName," successful" - ret=1 + if verbose(): print "import %s is done successfully" % componentName + # if import successfully, check that component is loadable + if not hasattr(module, componentName): + reason = "module %s is not loadable" % componentName + print reason + pass + pass except: import traceback + print "cannot import %s" % componentName traceback.print_exc() - print "import ",componentName," not possible" - return ret + reason = "cannot import %s" % componentName + return reason #------------------------------------------------------------------------- @@ -187,7 +194,8 @@ class SALOME_ContainerPy_i (Engines__POA.Container): ret = 0 instanceName = componentName + "_inst_" + `self._numInstance` interfaceName = componentName - return self.import_component(componentName), "" + reason = self.import_component(componentName) + return reason == "", reason #------------------------------------------------------------------------- diff --git a/src/KERNEL_PY/__init__.py b/src/KERNEL_PY/__init__.py index bf19736ef..9f3054773 100644 --- a/src/KERNEL_PY/__init__.py +++ b/src/KERNEL_PY/__init__.py @@ -105,7 +105,9 @@ ROOT_PYTHONPACKAGE_NAME="salome" # import os, sys from salome_utils import verbose -MATCH_ENDING_PATTERN="site-packages/salome" + +MATCH_ENDING_PATTERN="site-packages" + os.path.sep + "salome" + def extend_path(pname): for dir in sys.path: if not isinstance(dir, basestring) or not os.path.isdir(dir) or not dir.endswith(MATCH_ENDING_PATTERN): diff --git a/src/KERNEL_PY/kernel/parametric/study_exchange_vars.py b/src/KERNEL_PY/kernel/parametric/study_exchange_vars.py index ca9ec36ef..8d1588960 100644 --- a/src/KERNEL_PY/kernel/parametric/study_exchange_vars.py +++ b/src/KERNEL_PY/kernel/parametric/study_exchange_vars.py @@ -24,6 +24,7 @@ computation code. These Exchange Variables can be stored in a SObject in Salome study. """ +from xml.dom.minidom import getDOMImplementation, parse from salome.kernel.studyedit import getStudyEditor DEFAULT_NAME = "Variables" @@ -79,6 +80,32 @@ class ExchangeVariables: self.outputVarList = outputVarList self.refEntry = refEntry + def saveToXmlFile(self, filepath): + """ + Save this object to an XML file. + + :type filepath: string + :param filepath: path of the XML file. + + """ + doc = getDOMImplementation().createDocument(None, "variables", None) + top_el = doc.documentElement + top_el.setAttribute("version", "6.4") + input_variables_el = doc.createElement("input_variables") + top_el.appendChild(input_variables_el) + output_variables_el = doc.createElement("output_variables") + top_el.appendChild(output_variables_el) + for input_var in self.inputVarList: + input_var_el = doc.createElement("variable") + input_var_el.setAttribute("name", input_var.name) + input_variables_el.appendChild(input_var_el) + for output_var in self.outputVarList: + output_var_el = doc.createElement("variable") + output_var_el.setAttribute("name", output_var.name) + output_variables_el.appendChild(output_var_el) + f = open(filepath, "w") + f.write(doc.toprettyxml(indent = " ")) + f.close() def createSObjectForExchangeVariables(fatherSobj, exchangeVariables, name = DEFAULT_NAME, @@ -162,3 +189,29 @@ def getExchangeVariablesFromSObject(sobj): [Variable(name) for name in attr.GetStrArray(INPUT_VAR_NAMES)], [Variable(name) for name in attr.GetStrArray(OUTPUT_VAR_NAMES)], refEntry) + +def loadExchangeVariablesFromXmlFile(filepath): + """ + Load an :class:`ExchangeVariables` instance from an XML file. + + :type filepath: string + :param filepath: path of the XML file to load. + + :return: the newly created :class:`ExchangeVariables` instance. + + """ + doc = parse(filepath) + top_el = doc.documentElement + # Check version + version = top_el.getAttribute("version") + if version != "6.4": + raise Exception(self.tr("Unsupported version: %s" % version)) + input_variables_el = top_el.getElementsByTagName("input_variables")[0] + input_var_list = [Variable(input_var_el.getAttribute("name")) + for input_var_el + in input_variables_el.getElementsByTagName("variable")] + output_variables_el = top_el.getElementsByTagName("output_variables")[0] + output_var_list = [Variable(output_var_el.getAttribute("name")) + for output_var_el + in output_variables_el.getElementsByTagName("variable")] + return ExchangeVariables(input_var_list, output_var_list) diff --git a/src/KERNEL_PY/kernel/services.py b/src/KERNEL_PY/kernel/services.py index 8ccc81335..d5ed21e03 100644 --- a/src/KERNEL_PY/kernel/services.py +++ b/src/KERNEL_PY/kernel/services.py @@ -33,7 +33,8 @@ # SALOME development). import salome -if salome.lcc is None: +from deprecation import is_called_by_sphinx +if not is_called_by_sphinx() and salome.lcc is None: try: salome.salome_init() except Exception, e: diff --git a/src/Launcher/Launcher_Job.cxx b/src/Launcher/Launcher_Job.cxx index 6e62fb5d7..aee3751d0 100644 --- a/src/Launcher/Launcher_Job.cxx +++ b/src/Launcher/Launcher_Job.cxx @@ -339,6 +339,9 @@ Launcher::Job::checkMaximumDuration(const std::string & maximum_duration) std::size_t pos = edt_value.find(":"); if (edt_value != "") { + if (pos == edt_value.npos) { + throw LauncherException("[Launcher::Job::checkMaximumDuration] Error on definition: " + edt_value); + } std::string begin_edt_value = edt_value.substr(0, pos); std::string mid_edt_value = edt_value.substr(pos, 1); std::string end_edt_value = edt_value.substr(pos + 1, edt_value.npos); diff --git a/src/Launcher/Launcher_Job_SALOME.cxx b/src/Launcher/Launcher_Job_SALOME.cxx index b9005c2e6..f50f12da0 100644 --- a/src/Launcher/Launcher_Job_SALOME.cxx +++ b/src/Launcher/Launcher_Job_SALOME.cxx @@ -81,12 +81,7 @@ Launcher::Job_SALOME::buildSalomeScript(Batch::Parametre params) launch_script_stream << "export SALOME_TMP_DIR=" << work_directory << "/logs" << std::endl; // -- Generates Catalog Resources - std::string resource_protocol = "ssh"; - if (_resource_definition.ClusterInternalProtocol == rsh) - resource_protocol = "rsh"; - else if (_resource_definition.ClusterInternalProtocol == srun) - resource_protocol = "srun"; - + std::string resource_protocol = ParserResourcesType::protocolToString(_resource_definition.ClusterInternalProtocol); launch_script_stream << "if [ \"x$LIBBATCH_NODEFILE\" != \"x\" ]; then " << std::endl; launch_script_stream << "CATALOG_FILE=" << "CatalogResources_" << _launch_date << ".xml" << std::endl; launch_script_stream << "export USER_CATALOG_RESOURCES_FILE=" << "$CATALOG_FILE" << std::endl; @@ -111,12 +106,7 @@ Launcher::Job_SALOME::buildSalomeScript(Batch::Parametre params) launch_script_stream << "NS_PORT_FILE_NAME=`basename $NS_PORT_FILE_PATH` &&\n"; // Launch SALOME with an appli - launch_script_stream << _resource_definition.AppliPath << "/runAppli --terminal --ns-port-log=$NS_PORT_FILE_NAME "; - if (_resource_definition.ClusterInternalProtocol != rsh && - _resource_definition.ClusterInternalProtocol != ssh) - { - launch_script_stream << "--server-launch-cmd=" << resource_protocol << " "; - } + launch_script_stream << _resource_definition.AppliPath << "/runAppli --terminal --ns-port-log=$NS_PORT_FILE_NAME --server-launch-mode=fork "; launch_script_stream << "> logs/salome_" << _launch_date << ".log 2>&1 &&" << std::endl; launch_script_stream << "current=0 &&\n" << "stop=20 &&\n" diff --git a/src/Launcher/Makefile.am b/src/Launcher/Makefile.am index fdf3ce7d3..cf702075b 100644 --- a/src/Launcher/Makefile.am +++ b/src/Launcher/Makefile.am @@ -184,4 +184,9 @@ if WITH_LIBBATCH TestLauncher_CPPFLAGS += -DWITH_LIBBATCH endif -TestLauncher_LDADD = @LIBXML_LIBS@ ../ResourcesManager/libResourcesManager.la libLauncher.la @LIBBATCH_LIBS@ +TestLauncher_LDADD = \ + @LIBXML_LIBS@ \ + ../ResourcesManager/libResourcesManager.la \ + libLauncher.la \ + ../Utils/libOpUtil.la \ + @LIBBATCH_LIBS@ diff --git a/src/ResourcesManager/Makefile.am b/src/ResourcesManager/Makefile.am index c915a4896..e63b036d6 100755 --- a/src/ResourcesManager/Makefile.am +++ b/src/ResourcesManager/Makefile.am @@ -101,4 +101,5 @@ libResourcesManager_la_CPPFLAGS =\ libResourcesManager_la_LDFLAGS = -no-undefined -version-info=0:0:0 libResourcesManager_la_LIBADD =\ ../Basics/libSALOMEBasics.la \ + ../Utils/libOpUtil.la \ @LIBXML_LIBS@ diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx index db3f42d16..758fcec93 100755 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx @@ -28,6 +28,7 @@ // #include "SALOME_ResourcesCatalog_Handler.hxx" #include "Basics_Utils.hxx" +#include "Utils_SALOME_Exception.hxx" #include #include #include @@ -304,21 +305,15 @@ SALOME_ResourcesCatalog_Handler::ProcessMember(xmlNodePtr member_descr, ParserRe if (xmlHasProp(member_descr, (const xmlChar*)test_protocol)) { xmlChar* protocol= xmlGetProp(member_descr, (const xmlChar*)test_protocol); - switch (protocol[0]) + try { - case 'r': - resource.Protocol = rsh; - break; - case 's': - if (protocol[1] == 's') - resource.Protocol = ssh; - else - resource.Protocol = srun; - break; - default: - std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning found a machine with a bad protocol" << std::endl; - std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning this machine will not be added" << std::endl; - return false; + resource.Protocol = ParserResourcesType::stringToProtocol((const char *)protocol); + } + catch (SALOME_Exception e) + { + std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning found a machine with a bad protocol" << std::endl; + std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning this machine will not be added" << std::endl; + return false; } xmlFree(protocol); } @@ -332,21 +327,15 @@ SALOME_ResourcesCatalog_Handler::ProcessMember(xmlNodePtr member_descr, ParserRe if (xmlHasProp(member_descr, (const xmlChar*)test_cluster_internal_protocol)) { xmlChar* iprotocol= xmlGetProp(member_descr, (const xmlChar*)test_cluster_internal_protocol); - switch (iprotocol[0]) + try { - case 'r': - resource.ClusterInternalProtocol = rsh; - break; - case 's': - if (iprotocol[1] == 's') - resource.ClusterInternalProtocol = ssh; - else - resource.ClusterInternalProtocol = srun; - break; - default: - std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning found a machine with a bad protocol" << std::endl; - std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning this machine will not be added" << std::endl; - return false; + resource.ClusterInternalProtocol = ParserResourcesType::stringToProtocol((const char *)iprotocol); + } + catch (SALOME_Exception e) + { + std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning found a machine with a bad protocol" << std::endl; + std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning this machine will not be added" << std::endl; + return false; } xmlFree(iprotocol); } @@ -462,21 +451,14 @@ SALOME_ResourcesCatalog_Handler::ProcessMachine(xmlNodePtr machine_descr, Parser if (xmlHasProp(machine_descr, (const xmlChar*)test_protocol)) { xmlChar* protocol= xmlGetProp(machine_descr, (const xmlChar*)test_protocol); - switch ( protocol[0]) + try { - case 'r': - resource.Protocol = rsh; - break; - case 's': - if (protocol[1] == 's') - resource.Protocol = ssh; - else - resource.Protocol = srun; - break; - default: - // If it'not in all theses cases, the protocol is affected to rsh - resource.Protocol = rsh; - break; + resource.Protocol = ParserResourcesType::stringToProtocol((const char *)protocol); + } + catch (SALOME_Exception e) + { + // If it'not in all theses cases, the protocol is affected to rsh + resource.Protocol = rsh; } xmlFree(protocol); } @@ -486,21 +468,14 @@ SALOME_ResourcesCatalog_Handler::ProcessMachine(xmlNodePtr machine_descr, Parser if (xmlHasProp(machine_descr, (const xmlChar*)test_cluster_internal_protocol)) { xmlChar* iprotocol= xmlGetProp(machine_descr, (const xmlChar*)test_cluster_internal_protocol); - switch ( iprotocol[0]) + try { - case 'r': - resource.ClusterInternalProtocol = rsh; - break; - case 's': - if (iprotocol[1] == 's') - resource.ClusterInternalProtocol = ssh; - else - resource.ClusterInternalProtocol = srun; - break; - default: - // If it'not in all theses cases, the protocol is affected to rsh - resource.ClusterInternalProtocol = rsh; - break; + resource.ClusterInternalProtocol = ParserResourcesType::stringToProtocol((const char *)iprotocol); + } + catch (SALOME_Exception e) + { + // If it'not in all theses cases, the protocol is affected to rsh + resource.ClusterInternalProtocol = rsh; } xmlFree(iprotocol); } @@ -693,36 +668,12 @@ void SALOME_ResourcesCatalog_Handler::PrepareDocToXmlFile(xmlDocPtr theDoc) xmlNewProp(node, BAD_CAST test_appli_path, BAD_CAST (*iter).second.AppliPath.c_str()); xmlNewProp(node, BAD_CAST test_batch_queue, BAD_CAST (*iter).second.batchQueue.c_str()); xmlNewProp(node, BAD_CAST test_user_commands, BAD_CAST (*iter).second.userCommands.c_str()); - - switch ((*iter).second.Protocol) - { - case rsh: - xmlNewProp(node, BAD_CAST test_protocol, BAD_CAST "rsh"); - break; - case ssh: - xmlNewProp(node, BAD_CAST test_protocol, BAD_CAST "ssh"); - break; - case srun: - xmlNewProp(node, BAD_CAST test_protocol, BAD_CAST "srun"); - break; - default: - xmlNewProp(node, BAD_CAST test_protocol, BAD_CAST "rsh"); - } - - switch ((*iter).second.ClusterInternalProtocol) - { - case rsh: - xmlNewProp(node, BAD_CAST test_cluster_internal_protocol, BAD_CAST "rsh"); - break; - case ssh: - xmlNewProp(node, BAD_CAST test_cluster_internal_protocol, BAD_CAST "ssh"); - break; - case srun: - xmlNewProp(node, BAD_CAST test_cluster_internal_protocol, BAD_CAST "srun"); - break; - default: - xmlNewProp(node, BAD_CAST test_cluster_internal_protocol, BAD_CAST "rsh"); - } + xmlNewProp(node, + BAD_CAST test_protocol, + BAD_CAST ParserResourcesType::protocolToString((*iter).second.Protocol).c_str()); + xmlNewProp(node, + BAD_CAST test_cluster_internal_protocol, + BAD_CAST ParserResourcesType::protocolToString((*iter).second.ClusterInternalProtocol).c_str()); switch ((*iter).second.Mode) { diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.cxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.cxx index b3b2057ff..258837b72 100644 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.cxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.cxx @@ -21,6 +21,7 @@ // #include "SALOME_ResourcesCatalog_Parser.hxx" +#include "Utils_SALOME_Exception.hxx" #include #include @@ -128,6 +129,42 @@ void ResourceDataToSort::Print() const std::cout << _memInMB << std::endl; } + +std::string ParserResourcesType::protocolToString(AccessProtocolType protocol) +{ + switch (protocol) + { + case rsh: + return "rsh"; + case ssh: + return "ssh"; + case srun: + return "srun"; + case pbsdsh: + return "pbsdsh"; + case blaunch: + return "blaunch"; + default: + throw SALOME_Exception("Unknown protocol"); + } +} + +AccessProtocolType ParserResourcesType::stringToProtocol(const std::string & protocolStr) +{ + if (protocolStr == "rsh") + return rsh; + else if (protocolStr == "ssh") + return ssh; + else if (protocolStr == "srun") + return srun; + else if (protocolStr == "pbsdsh") + return pbsdsh; + else if (protocolStr == "blaunch") + return blaunch; + else + throw SALOME_Exception("Unknown protocol"); +} + void ParserResourcesType::Print() { std::ostringstream oss; @@ -138,8 +175,8 @@ void ParserResourcesType::Print() "NbOfProcPerNode : " << DataForSort._nbOfProcPerNode << std::endl << "CPUFreqMHz : " << DataForSort._CPUFreqMHz << std::endl << "MemInMB : " << DataForSort._memInMB << std::endl << - "Protocol : " << Protocol << std::endl << - "ClusterInternalProtocol : " << ClusterInternalProtocol << std::endl << + "Protocol : " << protocolToString(Protocol) << std::endl << + "ClusterInternalProtocol : " << protocolToString(ClusterInternalProtocol) << std::endl << "Mode : " << Mode << std::endl << "Batch : " << Batch << std::endl << "mpi : " << mpi << std::endl << @@ -170,23 +207,13 @@ void ParserResourcesType::Print() std::string ParserResourcesType::PrintAccessProtocolType() const { - if (Protocol == rsh) - return "rsh"; - else if (Protocol == srun) - return "srun"; - else - return "ssh"; + return protocolToString(Protocol); } std::string ParserResourcesType::PrintClusterInternalProtocol() const { - if (ClusterInternalProtocol == rsh) - return "rsh"; - else if (ClusterInternalProtocol == srun) - return "srun"; - else - return "ssh"; + return protocolToString(ClusterInternalProtocol); } std::string diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.hxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.hxx index 48800da40..9d6cb999f 100755 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.hxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.hxx @@ -41,7 +41,7 @@ #pragma warning(disable:4251) // Warning DLL Interface ... #endif -enum AccessProtocolType {rsh, ssh, srun}; +enum AccessProtocolType {rsh, ssh, srun, pbsdsh, blaunch}; enum AccessModeType {interactive, batch}; @@ -112,6 +112,9 @@ struct RESOURCESMANAGER_EXPORT ParserResourcesType void Print(); void Clear(); + static std::string protocolToString(AccessProtocolType protocol); + static AccessProtocolType stringToProtocol(const std::string & protocolStr); + std::string PrintAccessProtocolType() const; std::string PrintAccessModeType() const; std::string PrintBatchType() const; diff --git a/src/ResourcesManager/SALOME_ResourcesManager.cxx b/src/ResourcesManager/SALOME_ResourcesManager.cxx index ff499c6cc..144e1ffa8 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.cxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.cxx @@ -214,18 +214,8 @@ SALOME_ResourcesManager::GetResourceDefinition(const char * name) p_ptr->name = CORBA::string_dup(resource.Name.c_str()); p_ptr->hostname = CORBA::string_dup(resource.HostName.c_str()); - if( resource.Protocol == rsh ) - p_ptr->protocol = "rsh"; - else if( resource.Protocol == ssh ) - p_ptr->protocol = "ssh"; - else if( resource.Protocol == srun ) - p_ptr->protocol = "srun"; - if( resource.ClusterInternalProtocol == rsh ) - p_ptr->iprotocol = "rsh"; - else if( resource.ClusterInternalProtocol == ssh ) - p_ptr->iprotocol = "ssh"; - else if( resource.ClusterInternalProtocol == srun ) - p_ptr->iprotocol = "srun"; + p_ptr->protocol = ParserResourcesType::protocolToString(resource.Protocol).c_str(); + p_ptr->iprotocol = ParserResourcesType::protocolToString(resource.ClusterInternalProtocol).c_str(); p_ptr->username = CORBA::string_dup(resource.UserName.c_str()); p_ptr->applipath = CORBA::string_dup(resource.AppliPath.c_str()); p_ptr->componentList.length(resource.ComponentsList.size()); @@ -349,15 +339,12 @@ SALOME_ResourcesManager::AddResource(const Engines::ResourceDefinition& new_reso } std::string protocol = new_resource.protocol.in(); - if (protocol == "rsh") - resource.Protocol = rsh; - else if (protocol == "ssh") - resource.Protocol = ssh; - else if (protocol == "srun") - resource.Protocol = srun; - else if (protocol == "") - resource.Protocol = rsh; - else { + try + { + resource.Protocol = ParserResourcesType::stringToProtocol(protocol); + } + catch (SALOME_Exception e) + { INFOS("Bad protocol definition in AddResource: " << protocol); std::string message("Bad protocol definition in AddResource: "); message += protocol; @@ -365,15 +352,12 @@ SALOME_ResourcesManager::AddResource(const Engines::ResourceDefinition& new_reso } std::string iprotocol = new_resource.iprotocol.in(); - if (iprotocol == "rsh") - resource.ClusterInternalProtocol = rsh; - else if (iprotocol == "ssh") - resource.ClusterInternalProtocol = ssh; - else if (iprotocol == "srun") - resource.ClusterInternalProtocol = srun; - else if (iprotocol == "") - resource.ClusterInternalProtocol = rsh; - else { + try + { + resource.ClusterInternalProtocol = ParserResourcesType::stringToProtocol(iprotocol); + } + catch (SALOME_Exception e) + { INFOS("Bad iprotocol definition in AddResource: " << iprotocol); std::string message("Bad iprotocol definition in AddResource: "); message += iprotocol; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx index 67f16053a..6460eb4b6 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx @@ -568,8 +568,7 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const std::string& aStudyUrl, } } - std::string anOldName = aStudy->Name(); - aStudy->URL(aStudyUrl); + //std::string anOldName = aStudy->Name(); // To change for Save // Do not have to do a new file but just a Open??? Rewrite all informations after erasing evrything?? @@ -766,7 +765,6 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const std::string& aStudyUrl, hdf_group_study_structure->CloseOnDisk(); hdf_file->CloseOnDisk(); - aStudy->IsSaved(true); hdf_group_study_structure =0; // will be deleted by hdf_file destructor delete hdf_file; // recursively deletes all hdf objects... } @@ -808,7 +806,8 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const std::string& aStudyUrl, FILE* fp = fopen(aTmpFile.c_str(), "rb"); if(!fp) return false; char* buffer = new char[2047]; - while(!feof(fp)) { + int errors = 0; + while(!feof(fp) && !errors) { if((fgets(buffer, 2046, fp)) == NULL) break; size_t aLen = strlen(buffer); if(buffer[aLen-1] == '\n') buffer[aLen-1] = char(0); @@ -817,7 +816,7 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const std::string& aStudyUrl, #else aCmd = "mv -f \"" + aStudyTmpDir + std::string(buffer) + "\" \"" + SALOMEDSImpl_Tool::GetDirFromPath(aStudyUrl)+"\""; #endif - system(aCmd.c_str()); + errors = system(aCmd.c_str()); } delete []buffer; @@ -838,7 +837,13 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const std::string& aStudyUrl, rmdir(aStudyTmpDir.c_str()); #endif - return true; + if ( !errors ) { + // and finally, if all is done without errors, store new URL and mark study as Saved + aStudy->URL(aStudyUrl); + aStudy->IsSaved(true); + } + + return !errors; } //============================================================================ diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Tool.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_Tool.cxx index 89e955937..bf4461a84 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Tool.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Tool.cxx @@ -171,11 +171,11 @@ void SALOMEDSImpl_Tool::RemoveTemporaryFiles(const std::string& theDirectory, std::string SALOMEDSImpl_Tool::GetNameFromPath(const std::string& thePath) { if (thePath.empty()) return ""; int pos = thePath.rfind('/'); - if(pos > 0) return thePath.substr(pos+1, thePath.size()); + if(pos >= 0) return thePath.substr(pos+1, thePath.size()); pos = thePath.rfind('\\'); - if(pos > 0) return thePath.substr(pos+1, thePath.size()); + if(pos >= 0) return thePath.substr(pos+1, thePath.size()); pos = thePath.rfind('|'); - if(pos > 0) return thePath.substr(pos+1, thePath.size()); + if(pos >= 0) return thePath.substr(pos+1, thePath.size()); return thePath; } @@ -196,7 +196,7 @@ std::string SALOMEDSImpl_Tool::GetDirFromPath(const std::string& thePath) { if (pos < 0) pos = thePath.rfind('\\'); if (pos < 0) pos = thePath.rfind('|'); - if (pos > 0) + if (pos >= 0) path = thePath.substr(0, pos+1); else path = std::string(".") + separator;