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="<server_launch_cmd>",
- type="string",
+ # server launch mode
+ help_str = "Mode used to launch server processes (daemon or fork)."
+ o_slm = optparse.Option("--server-launch-mode",
+ metavar="<server_launch_mode>",
+ type="choice",
+ choices=["daemon","fork"],
action="store",
- dest="server_launch_cmd",
+ dest="server_launch_mode",
help=help_str)
# All options
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",
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)
#
# 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
class Server:
"""Generic class for CORBA server launch"""
- server_launch_args = []
+ server_launch_mode = "daemon"
def initArgs(self):
self.PID=None
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
#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
#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)
--- /dev/null
+# 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)
+
+# ----
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
"ToolsGUI",
"ViewerTools",
"VTKViewer",
+ "vtkEDFOverloads",
+ "vtkTools"
]
geom_list = [
"AdvancedGUI",
"IGESExport",
"IGESImport",
"MeasureGUI",
+ "Material",
"NMTDS",
"NMTTools",
"OCC2VTK",
# --
for key in full_list:
content = content.replace("-l%s"%(key), "${%s}"%(key))
+
pass
# --
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:
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})
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":
# --
newlines.append("""
set(VERSION 6.4.0)
+ set(SHORT_VERSION 6.4)
set(XVERSION 0x060400)
""")
pass
# --
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]))
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:
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']:
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
# --
# --
- 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
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
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)
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):
--- /dev/null
+#!/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
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);
// "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
//=============================================================================
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;
}
}
- const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesDescr(resource_name);
- o << getCommandToRunProcess(resInfo.Protocol);
-
if (isPythonContainer(params.container_name))
o << "SALOME_ContainerPy.py ";
else
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=<user>")
- 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");
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");
std::set<pid_t> 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;
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
#-------------------------------------------------------------------------
ret = 0
instanceName = componentName + "_inst_" + `self._numInstance`
interfaceName = componentName
- return self.import_component(componentName), ""
+ reason = self.import_component(componentName)
+ return reason == "", reason
#-------------------------------------------------------------------------
#
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):
Salome study.
"""
+from xml.dom.minidom import getDOMImplementation, parse
from salome.kernel.studyedit import getStudyEditor
DEFAULT_NAME = "Variables"
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,
[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)
# 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:
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);
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;
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"
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@
libResourcesManager_la_LDFLAGS = -no-undefined -version-info=0:0:0
libResourcesManager_la_LIBADD =\
../Basics/libSALOMEBasics.la \
+ ../Utils/libOpUtil.la \
@LIBXML_LIBS@
//
#include "SALOME_ResourcesCatalog_Handler.hxx"
#include "Basics_Utils.hxx"
+#include "Utils_SALOME_Exception.hxx"
#include <iostream>
#include <sstream>
#include <map>
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);
}
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);
}
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);
}
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);
}
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)
{
//
#include "SALOME_ResourcesCatalog_Parser.hxx"
+#include "Utils_SALOME_Exception.hxx"
#include <iostream>
#include <sstream>
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;
"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 <<
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
#pragma warning(disable:4251) // Warning DLL Interface ...
#endif
-enum AccessProtocolType {rsh, ssh, srun};
+enum AccessProtocolType {rsh, ssh, srun, pbsdsh, blaunch};
enum AccessModeType {interactive, batch};
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;
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());
}
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;
}
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;
}
}
- 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??
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...
}
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);
#else
aCmd = "mv -f \"" + aStudyTmpDir + std::string(buffer) + "\" \"" + SALOMEDSImpl_Tool::GetDirFromPath(aStudyUrl)+"\"";
#endif
- system(aCmd.c_str());
+ errors = system(aCmd.c_str());
}
delete []buffer;
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;
}
//============================================================================
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;
}
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;