From: Gilles DAVID Date: Wed, 20 Sep 2017 13:18:39 +0000 (+0200) Subject: Merge branch 'gdd_env_modules_in_config_appli' into gdd/merge_gdd_env_modules_in_conf... X-Git-Tag: V8_4_0b1~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3f353148bd2e75cc28815529b40ab04f3966460b;hp=c0fd3291e43706922bad49a75a8339024bb6b9b5;p=modules%2Fkernel.git Merge branch 'gdd_env_modules_in_config_appli' into gdd/merge_gdd_env_modules_in_config_appli Conflicts: bin/salomeContext.py --- diff --git a/CMakeLists.txt b/CMakeLists.txt index bf99f8ebb..a1e000f2d 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,7 @@ SET(${PROJECT_NAME_UC}_MINOR_VERSION 3) SET(${PROJECT_NAME_UC}_PATCH_VERSION 0) SET(${PROJECT_NAME_UC}_VERSION ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION}) -SET(${PROJECT_NAME_UC}_VERSION_DEV 0) +SET(${PROJECT_NAME_UC}_VERSION_DEV 1) # Common CMake macros # =================== diff --git a/CTestTestfileInstall.cmake.in b/CTestTestfileInstall.cmake.in index 254fb82f1..753228053 100644 --- a/CTestTestfileInstall.cmake.in +++ b/CTestTestfileInstall.cmake.in @@ -1,4 +1,4 @@ -# Copyright (C) 2015-2016 CEA/DEN, EDF R&D +# Copyright (C) 2015-2017 CEA/DEN, EDF R&D # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -17,7 +17,6 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -#SET(SALOME_TEST_DRIVER "$ENV{ABSOLUTE_APPLI_PATH}/bin/salome/appliskel/salome_test_driver.py") SET(SALOME_TEST_DRIVER "@CMAKE_INSTALL_PREFIX@/bin/salome/appliskel/salome_test_driver.py") SET(COMPONENT_NAME KERNEL) @@ -42,4 +41,5 @@ SUBDIRS( Launcher salomeInstance salomeCommand concurrentSession + salomeTest ) diff --git a/bin/appli_gen.py b/bin/appli_gen.py index 7dc3e8987..0dbab540b 100755 --- a/bin/appli_gen.py +++ b/bin/appli_gen.py @@ -1,6 +1,6 @@ #! /usr/bin/env python # -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2017 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 @@ -308,7 +308,7 @@ def install(prefix, config_file, verbose=0): os.path.join(home_dir, 'sha1_collections.txt')) pass else: - print "WARNING: context file does not exist" + print "WARNING: sha1 collections file does not exist" pass if _config.has_key("system_conf_path") and os.path.isfile(_config["system_conf_path"]): diff --git a/bin/appliskel/salome_tester/README b/bin/appliskel/salome_tester/README index 6e0eb4f52..4b7186f2c 100644 --- a/bin/appliskel/salome_tester/README +++ b/bin/appliskel/salome_tester/README @@ -1,4 +1,4 @@ -Copyright (C) 2015-2016 CEA/DEN, EDF R&D, OPEN CASCADE +Copyright (C) 2015-2017 CEA/DEN, EDF R&D, OPEN CASCADE This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -32,11 +32,12 @@ Each module test folder must contain: - install test files in /bin/salome/test/ - install the CTestTestfileInstall.cmake file (see below) as /bin/salome/test/CTestTestfile.cmake (rename file) - a CTestTestfileInstall.cmake that: - - declare tests requiring a SALOME session + - declare tests requiring a SALOME session, or tests that do not require a SALOME session but to be tested in SALOME execution environment. -The CTestTestfileInstall.cmake can also declare unit tests already declared in CMakeLists.txt. Actually CTestTestfileInstall.cmake declare all tests that will be runnable from SALOME application. This file MUST NOT use cmake environment variables. -It can refer the ABSOLUTE_APPLI_PATH variable (automatically set when using application). -If a test has to be run inside a SALOME session, use the salome_test_driver.py script that need as arguments a timeout, the test file to be run and its arguments. +The CTestTestfileInstall.cmake can also declare unit tests already declared in CMakeLists.txt. Actually CTestTestfileInstall.cmake declares all tests that will be runnable from SALOME application. For easier maintenance shared tests may be declared in a dedicated tests.set file which is then included in both CMakeLists.txt and CTestTestfileInstall.cmake files: + INCLUDE(tests.set) + +The CTestTestfileInstall.cmake file MUST NOT use cmake environment variables. It can refer the ABSOLUTE_APPLI_PATH variable (automatically set when using application). If a test has to be run inside a SALOME session, use the salome_test_driver.py script that need as arguments a timeout, the test file to be run and its arguments. SET(SALOME_TEST_DRIVER "$ENV{ABSOLUTE_APPLI_PATH}/bin/salome/appliskel/salome_test_driver.py") SET(TIMEOUT 500) ADD_TEST(SalomeLauncher python ${SALOME_TEST_DRIVER} ${TIMEOUT} test_launcher.py) diff --git a/bin/appliskel/salome_tester/salome_instance.py b/bin/appliskel/salome_tester/salome_instance.py index 8fb347e92..23bb9c397 100644 --- a/bin/appliskel/salome_tester/salome_instance.py +++ b/bin/appliskel/salome_tester/salome_instance.py @@ -1,4 +1,4 @@ -# Copyright (C) 2015-2016 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2015-2017 CEA/DEN, EDF R&D, OPEN CASCADE # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -36,21 +36,22 @@ class SalomeInstance(object): @staticmethod def start(shutdown_servers=False, with_gui=False, args=[]): import tempfile - log = tempfile.NamedTemporaryFile(suffix='_nsport.log', delete=False) + log = tempfile.NamedTemporaryFile(suffix='_nsport', delete=True) + port_log = log.name log.close() - + port_log = port_log + "-%s.log"%(os.getpid()) instance_args = [ - "--ns-port-log=%s"%log.name, + "--ns-port-log=%s"%port_log, "--shutdown-servers=%d"%shutdown_servers ] + args salome_instance = SalomeInstance() salome_instance.__run(args=instance_args, with_gui=with_gui) - with open(log.name) as f: + with open(port_log) as f: salome_instance.port = int(f.readline()) - os.remove(log.name) + os.remove(port_log) return salome_instance # diff --git a/bin/appliskel/salome_tester/salome_test_driver.py b/bin/appliskel/salome_tester/salome_test_driver.py index 7b119d176..478d012da 100644 --- a/bin/appliskel/salome_tester/salome_test_driver.py +++ b/bin/appliskel/salome_tester/salome_test_driver.py @@ -26,18 +26,6 @@ import os import subprocess import signal -# Run test -def runTest(command): - print "Running:", " ".join(command) - p = subprocess.Popen(command) - p.communicate() - res = p.returncode - # About res value: - # A negative value -N indicates that the child was terminated by signal N (Unix only). - # On Unix, the value 11 generally corresponds to a segmentation fault. - return res -# - # Timeout management class TimeoutException(Exception): """Exception raised when test timeout is reached.""" @@ -82,7 +70,15 @@ if __name__ == "__main__": try: salome_instance = SalomeInstance.start(shutdown_servers=True) port = salome_instance.get_port() - res = runTest(test_and_args) + # Run the test + print "Running:", " ".join(test_and_args) + p = subprocess.Popen(test_and_args) + pid = p.pid + p.communicate() + res = p.returncode + # About res value: + # A negative value -N indicates that the child was terminated by signal N (Unix only). + # On Unix, the value 11 generally corresponds to a segmentation fault. except TimeoutException: print "FAILED : timeout(%s) is reached"%timeout_delay except: @@ -91,6 +87,7 @@ if __name__ == "__main__": pass try: salome_instance.stop() + os.kill(pid, signal.SIGTERM) except: pass if sys.platform == 'win32': diff --git a/bin/appliskel/tests/CMakeLists.txt b/bin/appliskel/tests/CMakeLists.txt index dd4c93082..da311738a 100644 --- a/bin/appliskel/tests/CMakeLists.txt +++ b/bin/appliskel/tests/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2013-2016 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2013-2017 CEA/DEN, EDF R&D, OPEN CASCADE # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -20,3 +20,4 @@ ADD_SUBDIRECTORY(concurrentSession) ADD_SUBDIRECTORY(salomeInstance) ADD_SUBDIRECTORY(salomeCommand) +ADD_SUBDIRECTORY(salomeTest) diff --git a/bin/appliskel/tests/concurrentSession/TestConcurrentSession.py b/bin/appliskel/tests/concurrentSession/TestConcurrentSession.py index 2a8a1275f..110a5d52f 100644 --- a/bin/appliskel/tests/concurrentSession/TestConcurrentSession.py +++ b/bin/appliskel/tests/concurrentSession/TestConcurrentSession.py @@ -1,4 +1,4 @@ -# Copyright (C) 2013-2016 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2013-2017 CEA/DEN, EDF R&D, OPEN CASCADE # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -122,9 +122,5 @@ class TestConcurrentLaunch(unittest.TestCase): # if __name__ == "__main__": - if not os.path.isfile("hello.py"): - with open("hello.py", "w") as f: - f.write("print 'Hello!'") - unittest.main() # diff --git a/bin/appliskel/tests/concurrentSession/TestMinimalExample.py b/bin/appliskel/tests/concurrentSession/TestMinimalExample.py index 016453540..4498d6934 100644 --- a/bin/appliskel/tests/concurrentSession/TestMinimalExample.py +++ b/bin/appliskel/tests/concurrentSession/TestMinimalExample.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2013-2016 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2013-2017 CEA/DEN, EDF R&D, OPEN CASCADE # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -68,18 +68,18 @@ class TestMinimalExample(unittest.TestCase): p.join() # Try to get specific port number - p = multiprocessing.Process(target=port_reservation, args=(obtained_ports, 2812, self,)) + p = multiprocessing.Process(target=port_reservation, args=(obtained_ports, 2899, self, 2899,)) p.start() p.join() # Release port - print "release port 2812" - p = multiprocessing.Process(target=releasePort, args=(2812,)) + print "release port 2899" + p = multiprocessing.Process(target=releasePort, args=(2899,)) p.start() p.join() # Try to get specific port number - p = multiprocessing.Process(target=port_reservation, args=(obtained_ports, 2812, self, 2812,)) + p = multiprocessing.Process(target=port_reservation, args=(obtained_ports, 2899, self, 2899,)) p.start() p.join() diff --git a/bin/appliskel/tests/concurrentSession/hello.py b/bin/appliskel/tests/concurrentSession/hello.py new file mode 100644 index 000000000..54ec0a01f --- /dev/null +++ b/bin/appliskel/tests/concurrentSession/hello.py @@ -0,0 +1 @@ +print 'Hello!' diff --git a/bin/appliskel/tests/salomeTest/CMakeLists.txt b/bin/appliskel/tests/salomeTest/CMakeLists.txt new file mode 100644 index 000000000..da05dd540 --- /dev/null +++ b/bin/appliskel/tests/salomeTest/CMakeLists.txt @@ -0,0 +1,31 @@ +# Copyright (C) 2017 CEA/DEN, EDF R&D +# +# 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, or (at your option) any later version. +# +# 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 +# + +FILE(GLOB py_scripts "${CMAKE_CURRENT_SOURCE_DIR}/*.py") +FILE(GLOB sh_scripts "${CMAKE_CURRENT_SOURCE_DIR}/*.sh") +LIST(APPEND scripts ${py_scripts}) +LIST(APPEND scripts ${sh_scripts}) + +# Application tests +INSTALL(FILES CTestTestfileInstall.cmake + DESTINATION ${KERNEL_TEST_DIR}/salomeTest + RENAME CTestTestfile.cmake) + +INSTALL(FILES ${scripts} + DESTINATION ${KERNEL_TEST_DIR}/salomeTest) diff --git a/bin/appliskel/tests/salomeTest/CTestTestfileInstall.cmake b/bin/appliskel/tests/salomeTest/CTestTestfileInstall.cmake new file mode 100644 index 000000000..c4df885bb --- /dev/null +++ b/bin/appliskel/tests/salomeTest/CTestTestfileInstall.cmake @@ -0,0 +1,36 @@ +# Copyright (C) 2017 CEA/DEN, EDF R&D +# +# 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, or (at your option) any later version. +# +# 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 +# + +SET(tname salome_test) + +SET(TEST_NAME ${COMPONENT_NAME}_SALOME_TEST_${tname}_bash) +ADD_TEST(${TEST_NAME} bash ${tname}.sh) +SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}" TIMEOUT ${TIMEOUT} WILL_FAIL ON) + +SET(TEST_NAME ${COMPONENT_NAME}_SALOME_TEST_${tname}_shell) +ADD_TEST(${TEST_NAME} bash ${tname}_in_shell.sh) +SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}" TIMEOUT ${TIMEOUT} WILL_FAIL ON) + +SET(TEST_NAME ${COMPONENT_NAME}_SALOME_TEST_${tname}_py) +ADD_TEST(${TEST_NAME} python ${tname}.py) +SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}" TIMEOUT ${TIMEOUT} WILL_FAIL ON) + +SET(TEST_NAME ${COMPONENT_NAME}_SALOME_TEST_${tname}_driver) +ADD_TEST(${TEST_NAME} python ${SALOME_TEST_DRIVER} ${TIMEOUT} ${tname}.py) +SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}" TIMEOUT ${TIMEOUT} WILL_FAIL ON) diff --git a/bin/appliskel/tests/salomeTest/salome_test.py b/bin/appliskel/tests/salomeTest/salome_test.py new file mode 100644 index 000000000..6119509e7 --- /dev/null +++ b/bin/appliskel/tests/salomeTest/salome_test.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python +# Copyright (C) 2017 CEA/DEN, EDF R&D +# +# 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, or (at your option) any later version. +# +# 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 +# + +import unittest + +class TestSalomeTest(unittest.TestCase): + + def testMustPass(self): + assert(True) + + def testMustFail(self): + assert(False) + +if __name__ == "__main__": + unittest.main() diff --git a/bin/appliskel/tests/salomeTest/salome_test.sh b/bin/appliskel/tests/salomeTest/salome_test.sh new file mode 100644 index 000000000..cba080ae8 --- /dev/null +++ b/bin/appliskel/tests/salomeTest/salome_test.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# Copyright (C) 2017 CEA/DEN, EDF R&D +# +# 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, or (at your option) any later version. +# +# 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 +# + +set -e # fail when any subcommand fails + +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done +CALLDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + +python ${CALLDIR}/salome_test.py diff --git a/bin/appliskel/tests/salomeTest/salome_test_in_shell.sh b/bin/appliskel/tests/salomeTest/salome_test_in_shell.sh new file mode 100644 index 000000000..fd00f8b76 --- /dev/null +++ b/bin/appliskel/tests/salomeTest/salome_test_in_shell.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# Copyright (C) 2017 CEA/DEN, EDF R&D +# +# 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, or (at your option) any later version. +# +# 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 +# + +set -e # fail when any subcommand fails + +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done +CALLDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + +echo ABSOLUTE_APPLI_PATH: $ABSOLUTE_APPLI_PATH +$ABSOLUTE_APPLI_PATH/salome shell -- python ${CALLDIR}/salome_test.py diff --git a/bin/nameserver.py b/bin/nameserver.py index f9d1a3a2c..37061547d 100755 --- a/bin/nameserver.py +++ b/bin/nameserver.py @@ -25,7 +25,7 @@ import os, sys, re, socket #import commands from server import Server -from Utils_Identity import getShortHostName +from salome_utils import getHostName from launchConfigureParser import verbose # ----------------------------------------------------------------------------- @@ -46,13 +46,8 @@ class NamingServer(Server): except: pass - if verbose(): print "Name Service... ", - #hname=os.environ["HOST"] #commands.getoutput("hostname") - if sys.platform == "win32": - hname = getShortHostName(); - else: - hname = socket.gethostname(); - #print "hname=",hname + if verbose(): print "Name Service... " + hname = getHostName() with open(os.environ["OMNIORB_CONFIG"]) as f: ss = re.findall("NameService=corbaname::" + hname + ":\d+", f.read()) diff --git a/bin/runConsole.py b/bin/runConsole.py index 51f9fe2ba..9639291f7 100644 --- a/bin/runConsole.py +++ b/bin/runConsole.py @@ -62,7 +62,7 @@ For example: (options, args) = parser.parse_args(args) except Exception, e: print e - return + return {}, [] return options, args # @@ -131,7 +131,7 @@ def __get_running_session(requested_port=None, lastInstanceByDefault=False): return host, port, filename # -import CORBA +from omniORB import CORBA import CosNaming import orbmodule @@ -198,7 +198,7 @@ def connect(args=None, env=None): options, args = __parse_args(args) host, port, filename = __get_running_session(options.port) if not port: - return 0 + return 1 cmd = [ "os.environ['OMNIORB_CONFIG'] = '%s'"%filename, @@ -215,7 +215,8 @@ def connect(args=None, env=None): absoluteAppliPath = os.getenv('ABSOLUTE_APPLI_PATH','') env_copy = os.environ.copy() proc = subprocess.Popen(['python', os.path.join(absoluteAppliPath,"bin","salome","runConsole.py"), pickle.dumps(cmd)], shell=False, close_fds=True, env=env_copy) - return proc.communicate() + proc.communicate() + return proc.returncode # if __name__ == "__main__": diff --git a/bin/runSalome.py b/bin/runSalome.py index 33886c27f..243ec39c1 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -189,10 +189,18 @@ class RegistryServer(Server): # --- class ContainerCPPServer(Server): - def __init__(self,args): + def __init__(self,args,with_gui=False): self.args=args self.initArgs() self.CMD=['SALOME_Container','FactoryServer'] + if not with_gui and self.args["valgrind_session"]: + l = ["valgrind"] + val = os.getenv("VALGRIND_OPTIONS") + if val: + l += val.split() + pass + self.CMD = l + self.CMD + pass # --- @@ -543,7 +551,7 @@ def startSalome(args, modules_list, modules_root_dir): # if ('cppContainer' in args['standalone']) | (args["gui"] == 0) : - myServer=ContainerCPPServer(args) + myServer=ContainerCPPServer(args, with_gui=args["gui"]!=0) myServer.run() if sys.platform == "win32": clt.waitNS("/Containers/" + theComputer + "/FactoryServer") diff --git a/bin/runSession.py b/bin/runSession.py index c83ef01a1..761e5d023 100644 --- a/bin/runSession.py +++ b/bin/runSession.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2017 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 @@ -29,7 +29,7 @@ import socket import subprocess import re from salomeContextUtils import getScriptsAndArgs, formatScriptsAndArgs, getShortAndExtraArgs -from salome_utils import getUserName +from salome_utils import getUserName, getShortHostName # Use to display newlines (\n) in epilog class MyParser(OptionParser): @@ -123,7 +123,7 @@ User "myself" connects to remotemachine to run the script concatenate.py in (options, args) = parser.parse_args(short_args) except Exception, e: print e - return + return None, [] port = options.port host = options.host @@ -152,7 +152,7 @@ User "myself" connects to remotemachine to run the script concatenate.py in else: if not host: # only PORT is given - host = socket.gethostname() + host = getShortHostName() # both MACHINE and PORT are given _writeConfigFile(port, host) # @@ -160,7 +160,7 @@ User "myself" connects to remotemachine to run the script concatenate.py in os.environ['NSHOST'] = host # determine running mode, taht is either 'local' or 'remote' - here = socket.gethostname() + here = getShortHostName() mode = "local" if host != here and host != "localhost" and host != "no_host": mode="remote" @@ -215,7 +215,7 @@ def __runLocalSession(command): sys.stderr.write("".join(errmsg)) sys.exit(1) - return ("".join(outmsg), "".join(errmsg)) + return 0 else: absoluteAppliPath = os.getenv('ABSOLUTE_APPLI_PATH','') if sys.platform == "win32": @@ -223,7 +223,8 @@ def __runLocalSession(command): else: cmd = ["/bin/bash", "--rcfile", absoluteAppliPath + "/.bashrc" ] proc = subprocess.Popen(cmd, shell=False, close_fds=True) - return proc.communicate() + proc.communicate() + return proc.returncode # def __copyFiles(user, machine, script, infiles, outfiles): @@ -283,10 +284,10 @@ def __copyFiles(user, machine, script, infiles, outfiles): def __runRemoteSession(sa_obj, params): if not params.user: print "ERROR: The user login on remote machine MUST be given." - return + return 1 if not params.directory: print "ERROR: The remote directory MUST be given." - return + return 1 # sa_obj.script may be 'python script.py' --> only process .py file header = " ".join(sa_obj.script.split()[:-1]) @@ -318,6 +319,7 @@ def __runRemoteSession(sa_obj, params): os.system(command) os.remove(tmp_script) + return 0 # def runSession(params, args): @@ -328,6 +330,10 @@ def runSession(params, args): return __runLocalSession(command) elif params.mode == "remote": + any_error = 0 for sa_obj in scriptArgs: - __runRemoteSession(sa_obj, params) + ok = __runRemoteSession(sa_obj, params) + if not ok: + any_error = 1 + return any_error # diff --git a/bin/salomeContext.py b/bin/salomeContext.py index f4bbf8861..92878a52a 100644 --- a/bin/salomeContext.py +++ b/bin/salomeContext.py @@ -91,7 +91,7 @@ class SalomeContext: if len(configFileNames) == 0: raise SalomeContextException("No configuration files given") - reserved=['PATH', 'DYLD_FALLBACK_LIBRARY_PATH', 'DYLD_LIBRARY_PATH', 'LD_LIBRARY_PATH', 'PYTHONPATH', 'MANPATH', 'PV_PLUGIN_PATH', 'INCLUDE', 'LIBPATH', 'SALOME_PLUGINS_PATH', 'LIBRARY_PATH'] + reserved=['PATH', 'DYLD_FALLBACK_LIBRARY_PATH', 'DYLD_LIBRARY_PATH', 'LD_LIBRARY_PATH', 'PYTHONPATH', 'MANPATH', 'PV_PLUGIN_PATH', 'INCLUDE', 'LIBPATH', 'SALOME_PLUGINS_PATH', 'LIBRARY_PATH', 'QT_PLUGIN_PATH'] for filename in configFileNames: basename, extension = os.path.splitext(filename) if extension == ".cfg": @@ -260,7 +260,7 @@ class SalomeContext: try: res = getattr(self, command)(options) # run appropriate method - return res or (None, None) + return res or 0 except SystemExit as ex: if ex.code != 0: self.getLogger().error("SystemExit %s in method %s.", ex.code, command) @@ -319,6 +319,7 @@ class SalomeContext: import runSalome runSalome.runSalome() + return 0 # def _setContext(self, args=None): @@ -328,7 +329,7 @@ class SalomeContext: print "*** SALOME context has already been set." print "*** Enter 'exit' (only once!) to leave SALOME context." print "***" - return + return 0 os.environ["SALOME_CONTEXT_SET"] = "yes" print "***" @@ -338,7 +339,8 @@ class SalomeContext: cmd = ["/bin/bash"] proc = subprocess.Popen(cmd, shell=False, close_fds=True) - return proc.communicate() + proc.communicate() + return proc.returncode() # def _runSession(self, args=None): @@ -373,7 +375,7 @@ class SalomeContext: ports = args if not ports: print "Port number(s) not provided to command: salome kill " - return + return 1 from multiprocessing import Process from killSalomeWithPort import killMyPort @@ -383,7 +385,7 @@ class SalomeContext: p = Process(target = killMyPort, args=(port,)) p.start() p.join() - pass + return 0 # def _killAll(self, unused=None): @@ -405,6 +407,7 @@ class SalomeContext: from killSalome import killAllPorts killAllPorts() pass + return 0 # def _runTests(self, args=None): @@ -466,7 +469,7 @@ Available options are: if "-h" in args or "--help" in args: print usage + epilog - return + return 0 if "-p" in args or "--ports" in args: import PortManager @@ -498,7 +501,9 @@ Available options are: if "-v" in args or "--version" in args: print "Running with python", platform.python_version() - self._runAppli(["--version"]) + return self._runAppli(["--version"]) + + return 0 # def _showDoc(self, args=None): @@ -508,7 +513,7 @@ Available options are: modules = args if not modules: print "Module(s) not provided to command: salome doc " - return + return 1 appliPath = os.getenv("ABSOLUTE_APPLI_PATH") if not appliPath: @@ -616,7 +621,8 @@ if __name__ == "__main__": context = pickle.loads(sys.argv[1]) args = pickle.loads(sys.argv[2]) - context._startSalome(args) + status = context._startSalome(args) + sys.exit(status) else: usage() # diff --git a/bin/salome_utils.py b/bin/salome_utils.py index 52a73fdd0..4f4936f97 100644 --- a/bin/salome_utils.py +++ b/bin/salome_utils.py @@ -148,7 +148,6 @@ def getHostName(): 3. if fails, try HOST environment variable 4. if fails, return 'unknown' as default host name """ - import os try: import socket host = socket.gethostname() @@ -158,6 +157,11 @@ def getHostName(): if not host: host = os.getenv("HOSTNAME") if not host: host = os.getenv("HOST") if not host: host = "unknown" # 'unknown' is default host name + try: + socket.gethostbyname(host) + except: + host = "localhost" + pass return host # --- diff --git a/bin/setenv.py b/bin/setenv.py index 693a51feb..242f492cd 100755 --- a/bin/setenv.py +++ b/bin/setenv.py @@ -106,7 +106,7 @@ def get_config(silent=False, exeName=None): modules_list = [] if args.has_key("modules"): - modules_list += args["modules"] + modules_list += [a for a in args["modules"] if a.strip()] # KERNEL must be last in the list to locate it at the first place in PATH if args["gui"] : modules_list[:0] = ["GUI"] diff --git a/src/Communication_SWIG/libSALOME_Comm.i b/src/Communication_SWIG/libSALOME_Comm.i index 9a3c02114..7681ec35f 100644 --- a/src/Communication_SWIG/libSALOME_Comm.i +++ b/src/Communication_SWIG/libSALOME_Comm.i @@ -36,7 +36,7 @@ { PyObject* pdict = PyDict_New(); PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins()); - PyRun_String("import CORBA", Py_single_input, pdict, pdict); + PyRun_String("from omniORB import CORBA", Py_single_input, pdict, pdict); PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input, pdict, pdict); @@ -66,7 +66,7 @@ { PyObject* pdict = PyDict_New(); PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins()); - PyRun_String("import CORBA", Py_single_input, pdict, pdict); + PyRun_String("from omniORB import CORBA", Py_single_input, pdict, pdict); PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input, pdict, pdict); @@ -96,7 +96,7 @@ { PyObject* pdict = PyDict_New(); PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins()); - PyRun_String("import CORBA", Py_single_input, pdict, pdict); + PyRun_String("from omniORB import CORBA", Py_single_input, pdict, pdict); PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input, pdict, pdict); PyObject* orb = PyDict_GetItemString(pdict, "o"); @@ -114,7 +114,7 @@ { PyObject* pdict = PyDict_New(); PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins()); - PyRun_String("import CORBA", Py_single_input, pdict, pdict); + PyRun_String("from omniORB import CORBA", Py_single_input, pdict, pdict); PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input, pdict, pdict); PyObject* orb = PyDict_GetItemString(pdict, "o"); diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index cb8e76656..fcd1444b1 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2017 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 @@ -1045,6 +1045,9 @@ std::string SALOME_ContainerManager::BuildTemporaryFileName() { //build more complex file name to support multiple salome session std::string aFileName = Kernel_Utils::GetTmpFileName(); + std::ostringstream str_pid; + str_pid << ::getpid(); + aFileName = aFileName + "-" + str_pid.str(); #ifndef WIN32 aFileName += ".sh"; #else @@ -1196,7 +1199,7 @@ std::string SALOME_ContainerManager::GetMPIZeroNode(const std::string machine, c std::string command; std::string tmpFile = BuildTemporaryFileName(); const ParserResourcesType resInfo(_resManager->GetResourceDefinition(machine)); - + if(resInfo.Protocol == sh) { return resInfo.HostName; @@ -2055,4 +2058,3 @@ SALOME_ContainerManager::LaunchPaCONodeContainer(const std::string& command, return false; } #endif - diff --git a/src/KERNEL_PY/salome_test.py b/src/KERNEL_PY/salome_test.py index e0bdd983f..13f46c1b8 100755 --- a/src/KERNEL_PY/salome_test.py +++ b/src/KERNEL_PY/salome_test.py @@ -352,12 +352,9 @@ print "======================================================================" if salome.hasDesktop(): # in gui mode print "**** Importing pvserver... It can take some time." - from presentations import * import pvserver import pvsimple - my_paravis = pvserver.myPVServerService - #====================Stage1: Importing MED file==================== print "**** Stage1: Importing MED file" @@ -373,75 +370,34 @@ if salome.hasDesktop(): # in gui mode else: print "OK" - cell_entity = EntityType.CELL - node_entity = EntityType.NODE - - #====================Stage2: Displaying vector field=============== + #====================Stage2: Displaying presentation=============== - print "**** Stage3: Displaying vector field" + print "**** Stage2: Displaying presentation" print 'Get view...................', view = pvsimple.GetRenderView() if view is None: print "FAILED" else: - reset_view(view) print "OK" - print "Creating Scalar Map.......", - scalarmap = ScalarMapOnField(med_reader, node_entity, 'vitesse', 2) - if scalarmap is None: + print "Creating presentation.......", + prs = pvsimple.GetRepresentation(med_reader) + if prs is None: print "FAILED" else: - bar = get_bar() - bar.Orientation = 'Horizontal' - bar.Position = [0.1, 0.1] - bar.Position2 = [0.1, 0.25] - bar.AspectRatio = 3 + rep_list = view.Representations + for rep in rep_list: + if hasattr(rep, 'Visibility'): + rep.Visibility = (rep == prs) + pvsimple.Render(view=view) - display_only(scalarmap, view) - print "OK" - - view.ResetCamera() - - print "Creating Vectors..........", - vectors = VectorsOnField(med_reader, node_entity, 'vitesse', 2) - if vectors is None: - print "FAILED" - else: - display_only(vectors, view) - print "OK" - - print "Creating Iso Surfaces.....", - isosurfaces = IsoSurfacesOnField(med_reader, node_entity, 'vitesse', 2) - if isosurfaces is None: - print "FAILED" - else: - display_only(isosurfaces, view) - print "OK" - - print "Creating Cut Planes.......", - cutplanes = CutPlanesOnField(med_reader, node_entity, 'vitesse', 2, - nb_planes=30, orientation=Orientation.YZ) - if cutplanes is None: - print "FAILED" - else: - display_only(cutplanes, view) + # ---- surface representation + prs.SetRepresentationType('Surface') + view.ResetCamera() + print "OK" - print "Creating Scalar Map On Deformed Shape.......", - scalarmapondefshape = DeformedShapeAndScalarMapOnField(med_reader, - node_entity, - 'vitesse', 2, - None, - cell_entity, - 'pression') - if scalarmapondefshape is None: - print "FAILED" - else: - display_only(scalarmapondefshape, view) - print "OK" - else: # not in gui mode, Paravis can not be tested print diff --git a/src/Launcher/BatchTest.cxx b/src/Launcher/BatchTest.cxx index 788aca8b5..d81ef8a04 100644 --- a/src/Launcher/BatchTest.cxx +++ b/src/Launcher/BatchTest.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2017 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 @@ -22,6 +22,8 @@ #include "BatchTest.hxx" #include "Launcher.hxx" +#include "Basics_Utils.hxx" +#include "Basics_DirUtils.hxx" #ifdef WITH_LIBBATCH #include @@ -47,10 +49,8 @@ BatchTest::BatchTest(const Engines::ResourceDefinition& batch_descr) strftime(date, BUFSIZE, "%Y_%m_%d__%H_%M_%S", localtime(&curtime)); // Creating test temporary file - _test_filename = "/tmp/"; - _test_filename += std::string(date) + "_test_cluster_file_"; - _test_filename += _batch_descr.hostname.in(); _base_filename = std::string(date) + "_test_cluster_file_" + _batch_descr.hostname.in(); + _test_filename = Kernel_Utils::GetTmpDir() + _base_filename; #endif } diff --git a/src/Launcher/Launcher_Job.cxx b/src/Launcher/Launcher_Job.cxx index c52363bce..e046fd8cf 100644 --- a/src/Launcher/Launcher_Job.cxx +++ b/src/Launcher/Launcher_Job.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2009-2016 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2009-2017 CEA/DEN, EDF R&D, OPEN CASCADE // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -27,7 +27,7 @@ #include #endif -using namespace std; +#include Launcher::Job::Job() { @@ -590,7 +590,11 @@ Launcher::Job::common_job_params() strftime(date, BUFSIZE, "%Y_%m_%d__%H_%M_%S", localtime(&curtime)); if(!_resource_definition.working_directory.empty()) { - std::string job_dir = std::string("/job_") + date; + std::string date_dir = std::string("/job_") + date; + std::ostringstream str_pid; + str_pid << ::getpid(); + std::string job_dir = date_dir + "-" + str_pid.str(); + _work_directory = _resource_definition.working_directory + job_dir; } else diff --git a/src/Launcher/Launcher_Job_Command.cxx b/src/Launcher/Launcher_Job_Command.cxx index 0fb681c35..bdb0f2ec4 100644 --- a/src/Launcher/Launcher_Job_Command.cxx +++ b/src/Launcher/Launcher_Job_Command.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2009-2016 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2009-2017 CEA/DEN, EDF R&D, OPEN CASCADE // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -31,6 +31,8 @@ #define _chmod chmod #endif +#include + Launcher::Job_Command::Job_Command() {_job_type = "command";} Launcher::Job_Command::~Job_Command() {} @@ -46,7 +48,7 @@ Launcher::Job_Command::update_job() } #ifdef WITH_LIBBATCH -std::string +std::string Launcher::Job_Command::buildCommandScript(Batch::Parametre params, std::string launch_date) { // parameters @@ -54,10 +56,12 @@ Launcher::Job_Command::buildCommandScript(Batch::Parametre params, std::string l // File name std::string launch_date_port_file = launch_date; - std::string launch_script = Kernel_Utils::GetTmpDir() + "runCommand_" + _job_file_name + "_" + launch_date + ".sh"; + std::ostringstream str_pid; + str_pid << ::getpid(); + std::string launch_script = Kernel_Utils::GetTmpDir() + "runCommand_" + _job_file_name + "_" + launch_date + "-" + str_pid.str() + ".sh"; std::ofstream launch_script_stream; launch_script_stream.open(launch_script.c_str(), std::ofstream::out); - + // Script launch_script_stream << "#!/bin/sh -f" << std::endl; launch_script_stream << "cd " << work_directory << std::endl; diff --git a/src/Launcher/Launcher_Job_SALOME.cxx b/src/Launcher/Launcher_Job_SALOME.cxx index 75941e77b..ee2812c1b 100644 --- a/src/Launcher/Launcher_Job_SALOME.cxx +++ b/src/Launcher/Launcher_Job_SALOME.cxx @@ -31,6 +31,8 @@ #define _chmod chmod #endif +#include + Launcher::Job_SALOME::Job_SALOME() {} Launcher::Job_SALOME::~Job_SALOME() {} @@ -63,8 +65,9 @@ Launcher::Job_SALOME::buildSalomeScript(Batch::Parametre params) { // parameters std::string work_directory = params[Batch::WORKDIR].str(); - - std::string launch_script = Kernel_Utils::GetTmpDir() + "runSalome_" + _job_file_name + "_" + _launch_date + ".sh"; + std::ostringstream str_pid; + str_pid << ::getpid(); + std::string launch_script = Kernel_Utils::GetTmpDir() + "runSalome_" + _job_file_name + "_" + _launch_date + "-" + str_pid.str() + ".sh"; std::ofstream launch_script_stream; launch_script_stream.open(launch_script.c_str(), std::ofstream::out diff --git a/src/Launcher/Test/test_launcher.py b/src/Launcher/Test/test_launcher.py index 53fe67af5..546b0057f 100755 --- a/src/Launcher/Test/test_launcher.py +++ b/src/Launcher/Test/test_launcher.py @@ -5,6 +5,17 @@ import unittest import os import sys import time +import tempfile +import errno + +def mkdir_p(path): + try: + os.makedirs(path) + except OSError as exc: # Python >2.5 + if exc.errno == errno.EEXIST and os.path.isdir(path): + pass + else: + raise # Test of SalomeLauncher. # This test should be run in the salome environment, using "salome shell" @@ -19,12 +30,13 @@ class TestCompo(unittest.TestCase): @classmethod def setUpClass(cls): # Prepare the test directory - import shutil - cls.test_dir = os.path.join(os.getcwd(), "test_dir") - cls.suffix = time.strftime("-%Y-%m-%d-%H-%M-%S") - shutil.rmtree(cls.test_dir, ignore_errors=True) - os.mkdir(cls.test_dir) - + temp = tempfile.NamedTemporaryFile() + cls.test_dir = os.path.join(temp.name, "test_dir") + name = os.path.basename(temp.name) + temp.close() + cls.suffix = time.strftime("-%Y-%m-%d-%H-%M-%S")+"-%s"%(os.getpid()) + mkdir_p(cls.test_dir) + # load catalogs # mc = salome.naming_service.Resolve('/Kernel/ModulCatalog') # ior = salome.orb.object_to_string(mc) @@ -54,11 +66,11 @@ class TestCompo(unittest.TestCase): ############################## def test_salome_py_job(self): case_test_dir = os.path.join(TestCompo.test_dir, "salome_py") - os.mkdir(case_test_dir) - + mkdir_p(case_test_dir) + old_dir = os.getcwd() os.chdir(case_test_dir) - + # job script script_file = "myScript.py" job_script_file = os.path.join(case_test_dir, script_file) @@ -82,8 +94,8 @@ f.close() f = open(job_script_file, "w") f.write(script_text) f.close() - - local_result_dir = os.path.join(case_test_dir, "result_py_job") + + local_result_dir = os.path.join(case_test_dir, "result_py_job-") job_params = salome.JobParameters() job_params.job_type = "python_salome" job_params.job_file = job_script_file @@ -91,9 +103,9 @@ f.close() job_params.out_files = ["result.txt", "subdir"] job_params.resource_required = salome.ResourceParameters() job_params.resource_required.nb_proc = 1 - + launcher = salome.naming_service.Resolve('/SalomeLauncher') - + for resource in self.ressources: print "Testing python_salome job on ", resource job_params.result_directory = local_result_dir + resource @@ -130,14 +142,14 @@ f.close() pass #for os.chdir(old_dir) - + ############################## # test of command job type ############################## def test_command(self): case_test_dir = os.path.join(TestCompo.test_dir, "command") - os.mkdir(case_test_dir) - + mkdir_p(case_test_dir) + # job script data_file = "in.txt" script_file = "myEnvScript.py" @@ -166,7 +178,7 @@ f.close() f.write(script_text) f.close() os.chmod(abs_script_file, 0o755) - + #environement script env_file = "myEnv.sh" env_text = """export ENV_TEST_VAR="expected" @@ -174,14 +186,14 @@ f.close() f = open(os.path.join(case_test_dir, env_file), "w") f.write(env_text) f.close() - + # write data file f = open(os.path.join(case_test_dir, data_file), "w") f.write("to be copied") f.close() - + # job params - local_result_dir = os.path.join(case_test_dir, "result_com_job") + local_result_dir = os.path.join(case_test_dir, "result_com_job-") job_params = salome.JobParameters() job_params.job_type = "command" job_params.job_file = script_file @@ -191,7 +203,7 @@ f.close() job_params.local_directory = case_test_dir job_params.resource_required = salome.ResourceParameters() job_params.resource_required.nb_proc = 1 - + # create and launch the job launcher = salome.naming_service.Resolve('/SalomeLauncher') resManager= salome.lcc.getResourcesManager() @@ -205,7 +217,7 @@ f.close() # use the working directory of the resource resParams = resManager.GetResourceDefinition(resource) wd = os.path.join(resParams.working_directory, - "CommandJob_" + self.suffix) + "CommandJob" + self.suffix) job_params.work_directory = wd job_id = launcher.createJob(job_params) @@ -247,10 +259,10 @@ f.close() yacs_path = os.getenv("YACS_ROOT_DIR", "") if not os.path.isdir(yacs_path): self.skipTest("Needs YACS module to run. Please define YACS_ROOT_DIR.") - + case_test_dir = os.path.join(TestCompo.test_dir, "yacs") - os.mkdir(case_test_dir) - + mkdir_p(case_test_dir) + #environement script env_file = "myEnv.sh" env_text = """export ENV_TEST_VAR="expected" @@ -258,7 +270,7 @@ f.close() f = open(os.path.join(case_test_dir, env_file), "w") f.write(env_text) f.close() - + # job script script_text = """ @@ -285,14 +297,14 @@ f.close() f = open(job_script_file, "w") f.write(script_text) f.close() - - local_result_dir = os.path.join(case_test_dir, "result_yacs_job") + + local_result_dir = os.path.join(case_test_dir, "result_yacs_job-") job_params = salome.JobParameters() job_params.job_type = "yacs_file" job_params.job_file = job_script_file job_params.env_file = os.path.join(case_test_dir,env_file) job_params.out_files = ["result.txt"] - + # define the interval between two YACS schema dumps (3 seconds) import Engines job_params.specific_parameters = [Engines.Parameter("EnableDumpYACS", "3")] @@ -301,7 +313,7 @@ f.close() launcher = salome.naming_service.Resolve('/SalomeLauncher') resManager= salome.lcc.getResourcesManager() - + for resource in self.ressources: print "Testing yacs job on ", resource job_params.result_directory = local_result_dir + resource @@ -311,7 +323,7 @@ f.close() # use the working directory of the resource resParams = resManager.GetResourceDefinition(resource) wd = os.path.join(resParams.working_directory, - "YacsJob_" + self.suffix) + "YacsJob" + self.suffix) job_params.work_directory = wd job_id = launcher.createJob(job_params) @@ -352,7 +364,7 @@ f.close() launcher.getJobResults(job_id, "") self.verifyFile(os.path.join(job_params.result_directory, "result.txt"), "expected") - + ############################## # test of yacs job type using "--init_port" driver option ############################## @@ -360,10 +372,10 @@ f.close() yacs_path = os.getenv("YACS_ROOT_DIR", "") if not os.path.isdir(yacs_path): self.skipTest("Needs YACS module to run. Please define YACS_ROOT_DIR.") - + case_test_dir = os.path.join(TestCompo.test_dir, "yacs_opt") - os.mkdir(case_test_dir) - + mkdir_p(case_test_dir) + # job script script_text = """ @@ -398,14 +410,14 @@ f.close() f = open(job_script_file, "w") f.write(script_text) f.close() - - local_result_dir = os.path.join(case_test_dir, "result_yacsopt_job") + + local_result_dir = os.path.join(case_test_dir, "result_yacsopt_job-") job_params = salome.JobParameters() job_params.job_type = "yacs_file" job_params.job_file = job_script_file #job_params.env_file = os.path.join(case_test_dir,env_file) job_params.out_files = ["result.txt"] - + # define the interval between two YACS schema dumps (3 seconds) import Engines job_params.specific_parameters = [Engines.Parameter("YACSDriverOptions", @@ -416,7 +428,7 @@ f.close() launcher = salome.naming_service.Resolve('/SalomeLauncher') resManager= salome.lcc.getResourcesManager() - + for resource in self.ressources: print "Testing yacs job with options on ", resource job_params.result_directory = local_result_dir + resource @@ -426,7 +438,7 @@ f.close() # use the working directory of the resource resParams = resManager.GetResourceDefinition(resource) wd = os.path.join(resParams.working_directory, - "YacsJobOpt_" + self.suffix) + "YacsJobOpt" + self.suffix) job_params.work_directory = wd job_id = launcher.createJob(job_params) @@ -452,4 +464,4 @@ if __name__ == '__main__': # creat study import salome salome.salome_init() - unittest.main() \ No newline at end of file + unittest.main() diff --git a/src/LifeCycleCORBA_SWIG/Test/testcontainermanager.py b/src/LifeCycleCORBA_SWIG/Test/testcontainermanager.py index ea3dd25ad..793d3726f 100644 --- a/src/LifeCycleCORBA_SWIG/Test/testcontainermanager.py +++ b/src/LifeCycleCORBA_SWIG/Test/testcontainermanager.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2017 CEA/DEN, EDF R&D, OPEN CASCADE # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -18,6 +18,7 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # +import os import unittest import salome import Engines @@ -38,45 +39,46 @@ Test with catalog : """ def setUp(self): + self.container_name = "MyContainer-%s"%(os.getpid()) pass def test0(self): """""" rp=LifeCycleCORBA.ResourceParameters(policy="best",componentList=["PYHELLO"]) - p=LifeCycleCORBA.ContainerParameters(container_name="MyContainer",mode="start",resource_params=rp) + p=LifeCycleCORBA.ContainerParameters(container_name=self.container_name,mode="start",resource_params=rp) co=cm.GiveContainer( p ) host1=co.getHostName() - name1="/Containers/%s/MyContainer" % host1 + name1="/Containers/%s/%s" % (host1,self.container_name) self.assertEqual(co._get_name(), name1) co=cm.GiveContainer( p ) host2=co.getHostName() - name2="/Containers/%s/MyContainer" % host2 + name2="/Containers/%s/%s" % (host2,self.container_name) self.assertEqual(co._get_name(), name2) def test1(self): """""" rp=LifeCycleCORBA.ResourceParameters(policy="best",componentList=["PYHELLO"]) - p=LifeCycleCORBA.ContainerParameters(container_name="MyContainer",mode="get",resource_params=rp) + p=LifeCycleCORBA.ContainerParameters(container_name=self.container_name,mode="get",resource_params=rp) co=cm.GiveContainer( p ) host1=co.getHostName() - name1="/Containers/%s/MyContainer" % host1 + name1="/Containers/%s/%s" % (host1,self.container_name) self.assertEqual(co._get_name(), name1) co=cm.GiveContainer( p ) host2=co.getHostName() - name2="/Containers/%s/MyContainer" % host2 + name2="/Containers/%s/%s" % (host2,self.container_name) self.assertEqual(co._get_name(), name2) def test2(self): """""" rp=LifeCycleCORBA.ResourceParameters(policy="best",componentList=["PYHELLO"]) - p=LifeCycleCORBA.ContainerParameters(container_name="MyContainer",mode="getorstart",resource_params=rp) + p=LifeCycleCORBA.ContainerParameters(container_name=self.container_name,mode="getorstart",resource_params=rp) co=cm.GiveContainer( p ) host1=co.getHostName() - name1="/Containers/%s/MyContainer" % host1 + name1="/Containers/%s/%s" % (host1,self.container_name) self.assertEqual(co._get_name(), name1) co=cm.GiveContainer( p ) host2=co.getHostName() - name2="/Containers/%s/MyContainer" % host2 + name2="/Containers/%s/%s" % (host2,self.container_name) self.assertEqual(co._get_name(), name2) diff --git a/src/LifeCycleCORBA_SWIG/TestLifeCycleCORBA.py b/src/LifeCycleCORBA_SWIG/TestLifeCycleCORBA.py index 878797b5b..b0800d53d 100644 --- a/src/LifeCycleCORBA_SWIG/TestLifeCycleCORBA.py +++ b/src/LifeCycleCORBA_SWIG/TestLifeCycleCORBA.py @@ -47,7 +47,7 @@ except : print 'lcc.FindOrLoad_Component("FactoryServer","SalomeTestComponent") failed' import sys -import CORBA +from omniORB import CORBA import CosNaming orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID) obj = orb.resolve_initial_references("NameService") diff --git a/src/ParallelContainer/SALOME_ParallelContainer_i.cxx b/src/ParallelContainer/SALOME_ParallelContainer_i.cxx index 14a612934..7a593f665 100644 --- a/src/ParallelContainer/SALOME_ParallelContainer_i.cxx +++ b/src/ParallelContainer/SALOME_ParallelContainer_i.cxx @@ -444,7 +444,7 @@ Engines_Parallel_Container_i::create_component_instance_env(const char*genericRe void* handle = _library_map[impl_name]; if (handle) type_of_lib = "cpp"; - if (_library_map.count(aCompName) != 0 and !handle) + if (_library_map.count(aCompName) != 0 && !handle) type_of_lib = "python"; if (type_of_lib == "Not Loaded") diff --git a/src/SALOMESDS/SALOMESDS_Transaction.cxx b/src/SALOMESDS/SALOMESDS_Transaction.cxx index 6d85116f9..26fd9affe 100644 --- a/src/SALOMESDS/SALOMESDS_Transaction.cxx +++ b/src/SALOMESDS/SALOMESDS_Transaction.cxx @@ -276,11 +276,12 @@ void TransactionMultiKeyAddSession::addKeyValueInVarErrorIfAlreadyExistingNow(co _dsct->checkVarExistingAndDict(_var_name); TransactionAddKeyValueErrorIfAlreadyExisting ret(_dsct,_var_name,key,value); { - bool mustRollback(true); + ret.perform(); + /*bool mustRollback(true); TrustTransaction t; t.setTransaction(&ret,&mustRollback); t.operate(); - mustRollback=false;//important let this line to notify t that everything was OK + mustRollback=false;//important let this line to notify t that everything was OK*/ } ret.notify(); } diff --git a/src/Utils/Utils_Identity.cxx b/src/Utils/Utils_Identity.cxx index f989b62f6..04c2290c5 100644 --- a/src/Utils/Utils_Identity.cxx +++ b/src/Utils/Utils_Identity.cxx @@ -71,6 +71,8 @@ const char* get_adip( void ) #endif const hostent* pour_adip=gethostbyname(hostid.nodename); + if(pour_adip == NULL) + pour_adip=gethostbyname("localhost"); ASSERT(pour_adip!=NULL); const in_addr ip_addr=*(struct in_addr*)(pour_adip->h_addr) ; return duplicate(inet_ntoa(ip_addr));