From: vsr Date: Mon, 10 Dec 2018 14:22:28 +0000 (+0300) Subject: Merge branch 'V9_2_BR' X-Git-Tag: V9_3_0a1~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=63adcbd0efaf06dbbe685b35644eeaa0e6657ba4;hp=e5b98481928c437567b5379bc34d34bfdcebdaaf;p=modules%2Fkernel.git Merge branch 'V9_2_BR' --- diff --git a/CMakeLists.txt b/CMakeLists.txt index bba43b464..0a3a3fc6a 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,11 +30,11 @@ CMAKE_POLICY(SET CMP0003 NEW) STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC) SET(${PROJECT_NAME_UC}_MAJOR_VERSION 9) -SET(${PROJECT_NAME_UC}_MINOR_VERSION 1) +SET(${PROJECT_NAME_UC}_MINOR_VERSION 2) 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/bin/appliskel/tests/concurrentSession/TestConcurrentSession.py b/bin/appliskel/tests/concurrentSession/TestConcurrentSession.py index 59ff65c80..f11dc4d9c 100644 --- a/bin/appliskel/tests/concurrentSession/TestConcurrentSession.py +++ b/bin/appliskel/tests/concurrentSession/TestConcurrentSession.py @@ -44,7 +44,10 @@ class TestConcurrentLaunch(unittest.TestCase): return running_instances, processes # def __terminateInstances(self, running_instances): - while not running_instances.empty(): + import time + timeout = time.time() + 60*10 # the test duration is about 50 s, we reasonably assume a max duration of 10mn + + while not running_instances.empty() and time.time() < timeout: instance = running_instances.get() print("Terminate instance running on port", instance.get_port()) instance.stop() diff --git a/bin/salomeContext.py b/bin/salomeContext.py index 8e40e820a..0d65b3797 100644 --- a/bin/salomeContext.py +++ b/bin/salomeContext.py @@ -442,12 +442,12 @@ class SalomeContext: pass if softwares: for soft in softwares: - if versions.has_key(soft.upper()): + if soft.upper() in versions: print(soft.upper().rjust(max_len), versions[soft.upper()]) else: import collections od = collections.OrderedDict(sorted(versions.items())) - for name, version in od.iteritems(): + for name, version in od.items(): print(name.rjust(max_len), versions[name]) pass diff --git a/src/Container/SALOME_ComponentPy.py b/src/Container/SALOME_ComponentPy.py index 82d0400b9..4decad903 100755 --- a/src/Container/SALOME_ComponentPy.py +++ b/src/Container/SALOME_ComponentPy.py @@ -296,7 +296,7 @@ class SALOME_ComponentPy_i (Engines__POA.EngineComponent): aBuffer = "\0" if isMultiFile : aBuffer = "def RebuildData(): pass\n\0" - return (aBuffer, 1) + return (aBuffer.encode(), 1) #------------------------------------------------------------------------- diff --git a/src/KERNEL_PY/CMakeLists.txt b/src/KERNEL_PY/CMakeLists.txt index ceec5f393..6ccf92e26 100755 --- a/src/KERNEL_PY/CMakeLists.txt +++ b/src/KERNEL_PY/CMakeLists.txt @@ -28,6 +28,7 @@ SET(salomepython_PYTHON Help.py PyInterp.py batchmode_salome.py + kernel_test.py salome_test.py salome_kernel.py salome_study.py diff --git a/src/KERNEL_PY/kernel_test.py b/src/KERNEL_PY/kernel_test.py new file mode 100644 index 000000000..a1f9d1abd --- /dev/null +++ b/src/KERNEL_PY/kernel_test.py @@ -0,0 +1,114 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2018 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, 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 TestKernel(unittest.TestCase): + + def setUp(self): + import salome + salome.salome_init() + + def processGuiEvents(self): + import salome + if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(); + import SalomePyQt + SalomePyQt.SalomePyQt().processEvents() + + def test_modulecatalog(self): + """Quick test for Kernel module: check module catalogue""" + print() + print('Testing Kernel module: check module catalogue') + + import salome + + # ---- get module catalogue + print('... Get module catalogue') + import SALOME_ModuleCatalog + obj = salome.naming_service.Resolve('Kernel/ModulCatalog') + self.assertIsNotNone(obj) + catalog = obj._narrow(SALOME_ModuleCatalog.ModuleCatalog) + self.assertIsNotNone(catalog) + + # ---- ping catalog + catalog.ping() + + # ---- check some catalog's features + components = catalog.GetComponentList() + self.assertTrue('KERNEL' in components) + info = catalog.GetComponentInfo('KERNEL') + self.assertEqual(info.name, 'KERNEL') + self.assertEqual(info.type, SALOME_ModuleCatalog.OTHER) + + def test_dataserver(self): + """Quick test for Kernel module: check data server""" + print() + print('Testing Kernel module: check data server') + + import salome + + print('... Initialize study builder') + builder = salome.myStudy.NewBuilder() + self.assertIsNotNone(builder) + + print('... Create new component') + scomponent = builder.NewComponent('TEST') + self.assertIsNotNone(scomponent) + self.assertEqual(scomponent.ComponentDataType(), 'TEST') + self.assertEqual(scomponent.Depth(), 2) + + print('...... Assign AttributeName') + scomponent.SetAttrString('AttributeName', 'Test') + self.assertEqual(scomponent.GetName(), 'Test') + self.assertEqual(salome.myStudy.GetObjectPath(scomponent), '/Test') + self.processGuiEvents() + + print('... Create new object') + sobject = builder.NewObject(scomponent) + self.assertIsNotNone(sobject) + self.assertEqual(sobject.Tag(), 1) + self.assertEqual(sobject.Depth(), 3) + + print('...... Get father') + father = sobject.GetFatherComponent() + self.assertIsNotNone(father) + self.assertEqual(father.GetName(), scomponent.GetName()) + father = sobject.GetFather() + self.assertIsNotNone(father) + self.assertEqual(father.GetName(), scomponent.GetName()) + + print('...... Assign AttributeName') + sobject.SetAttrString('AttributeName', 'Object') + self.assertEqual(sobject.GetName(), 'Object') + self.assertEqual(salome.myStudy.GetObjectPath(sobject), '/Test/Object') + + print('...... Assign AttributeInteger') + attr = builder.FindOrCreateAttribute(sobject, 'AttributeInteger') + self.assertIsNotNone(attr) + attr.SetValue(123) + self.assertEqual(attr.Value(), 123) + self.processGuiEvents() + +if __name__ == '__main__': + unittest.main() diff --git a/src/KERNEL_PY/salome_test.py b/src/KERNEL_PY/salome_test.py old mode 100755 new mode 100644 index f7e6fffcb..4a15e3ecb --- a/src/KERNEL_PY/salome_test.py +++ b/src/KERNEL_PY/salome_test.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007 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 @@ -21,496 +21,35 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -print() -print("Perform quick test of the application by loading of the GEOM, SMESH, FIELDS, PARAVIS") -print("components and doing some operation within the components.") -print() - -import salome -import SALOME -import SALOMEDS -import os import sys -import time -import SALOME_ModuleCatalog - -step = 1 - -print("======================================================================") -print(" %d. Initialize study " % step); step+=1 -print("======================================================================") - -# initialize study -salome.salome_init() -# get study builder -builder = salome.myStudy.NewBuilder() -print("OK") - -print() - -print("======================================================================") -print(" %d. Retrieve module catalog " % step); step+=1 -print("======================================================================") - -obj = salome.naming_service.Resolve('Kernel/ModulCatalog') -catalog = obj._narrow(SALOME_ModuleCatalog.ModuleCatalog) -if not catalog: - - raise RuntimeError("Can't access module catalog") -print("OK") - -print() - -print("======================================================================") -print(" %d. Check modules availability in the module catalog " % step); step+=1 -print("======================================================================") - -for module in [ "GEOM", "SMESH", "MEDFactory", "PVSERVER"]: - print() - print("--- Check %s ..." % module) - comp = catalog.GetComponent(module) - if not comp: - raise RuntimeError("Component %s is not found in Module Catalog." % module) - print("OK") - pass - -print() - -print("======================================================================") -print(" %d. Test Data Server " % step); step+=1 -print("======================================================================") - -print() -print("--- Create new component ...") -comp = builder.NewComponent("TEST") -if not comp: - raise RuntimeError("Can't create new component") -print("OK") - -print() -print("--- Create AttributeName ...") -A = builder.FindOrCreateAttribute(comp, "AttributeName") -if not A: - raise RuntimeError("Can't create AttributeName attribute") -A.SetValue("TEST") -if A.Value() != "TEST": - raise RuntimeError("Error : wrong value of AttributeName") -print("OK") - -print() -print("--- Create AttributeReal ...") -A = builder.FindOrCreateAttribute(comp, "AttributeReal") -if not A: - raise RuntimeError("Can't create AttributeReal attribute") -A.SetValue(0.0001) -if A.Value() != 0.0001: - raise RuntimeError("Error : wrong value of AttributeReal") -print("OK") - -print() - -print("======================================================================") -print(" %d. Test Geometry " % step); step+=1 -print("======================================================================") - -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -ShapeTypeCompSolid = 1 -ShapeTypeSolid = 2 -ShapeTypeShell = 3 -ShapeTypeFace = 4 -ShapeTypeWire = 5 -ShapeTypeEdge = 6 -ShapeTypeVertex = 7 - -print() -print("--- Create a box ...") -box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) -idbox = geompy.addToStudy(box, "box") -box_obj = salome.myStudy.FindObjectByPath("/Geometry/box") -if not box_obj: - raise RuntimeError("Error : wrong value of AttributeReal") -print("OK") - -# ---- add shell from box in study -print() -print("--- Extract shell ...") -subShellList = geompy.SubShapeAll(box, ShapeTypeShell) -shell = subShellList[0] -name = geompy.SubShapeName(shell, box) -idshell = geompy.addToStudyInFather(box, shell, name) -print(name) -print("OK") - -# ---- add first face of box in study -print() -print("--- Extract face ...") -subShapeList = geompy.SubShapeAll(box, ShapeTypeFace) -face = subShapeList[0] -name = geompy.SubShapeName(face, box) -idface = geompy.addToStudyInFather(box, face, name) -print(name) -print("OK") - -# ---- add first edge of face in study -print() -print("--- Extract edge ...") -edgeList = geompy.SubShapeAll(face, ShapeTypeEdge) -edge = edgeList[0]; -name = geompy.SubShapeName(edge, face) -idedge = geompy.addToStudyInFather(face, edge, name) -print(name) -print("OK") - -# ---- update object browser -if salome.hasDesktop(): - salome.sg.updateObjBrowser(); - -print() - -print("======================================================================") -print(" %d. Test Mesh " % step); step+=1 -print("======================================================================") - -from salome.StdMeshers import StdMeshersBuilder -import SMESH -from salome.smesh import smeshBuilder - -smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") -if salome.hasDesktop(): - smeshgui = salome.ImportComponentGUI("SMESH") - smeshgui.Init(); -else: - smesh = smeshBuilder.New() - -# ---- create hypotheses - -stdMeshersEngine = "StdMeshersEngine" - -print() -print("--- Create hypotheses ...") - -print() -print("------ LocalLength ...") -hypLen1 = smesh.CreateHypothesis( "LocalLength", stdMeshersEngine ) -hypLen1.SetLength(100) -print(hypLen1.GetName()) -print(hypLen1.GetId()) -print(hypLen1.GetLength()) -if salome.hasDesktop(): - smeshgui.SetName(salome.ObjectToID(hypLen1), "Local_Length_100") -print("OK") - -print() -print("------ NumberOfSegments ...") -hypNbSeg1= smesh.CreateHypothesis( "NumberOfSegments", stdMeshersEngine ) -hypNbSeg1.SetNumberOfSegments(7) -print(hypNbSeg1.GetName()) -print(hypNbSeg1.GetId()) -print(hypNbSeg1.GetNumberOfSegments()) -if salome.hasDesktop(): - smeshgui.SetName(salome.ObjectToID(hypNbSeg1), "NumberOfSegments_7") -print("OK") - -print() -print("------ MaxElementArea [1] ...") -hypArea1 = smesh.CreateHypothesis( "MaxElementArea", stdMeshersEngine ) -hypArea1.SetMaxElementArea(2500) -print(hypArea1.GetName()) -print(hypArea1.GetId()) -print(hypArea1.GetMaxElementArea()) -if salome.hasDesktop(): - smeshgui.SetName(salome.ObjectToID(hypArea1), "MaxElementArea_2500") -print("OK") - -print() -print("------ MaxElementArea [2] ...") -hypArea2 = smesh.CreateHypothesis( "MaxElementArea", stdMeshersEngine ) -hypArea2.SetMaxElementArea(500) -print(hypArea2.GetName()) -print(hypArea2.GetId()) -print(hypArea2.GetMaxElementArea()) -if salome.hasDesktop(): - smeshgui.SetName(salome.ObjectToID(hypArea2), "MaxElementArea_500") -print("OK") - -# ---- create algorithms - -print() -print("--- Create algorithms ...") - -print() -print("------ Regular_1D ...") -algoReg = smesh.CreateHypothesis( "Regular_1D", stdMeshersEngine ) -listHyp = algoReg.GetCompatibleHypothesis() -for hyp in listHyp: - print(hyp) -print(algoReg.GetName()) -print(algoReg.GetId()) -if salome.hasDesktop(): - smeshgui.SetName(salome.ObjectToID(algoReg), "Regular_1D" ) -print("OK") - -print() -print("------ MEFISTO_2D ...") -algoMef = smesh.CreateHypothesis( "MEFISTO_2D", stdMeshersEngine ) -listHyp=algoMef.GetCompatibleHypothesis() -for hyp in listHyp: - print(hyp) -print(algoMef.GetName()) -print(algoMef.GetId()) -if salome.hasDesktop(): - smeshgui.SetName(salome.ObjectToID(algoMef), "MEFISTO_2D" ) -print("OK") - -# ---- create mesh on the box, apply hypotheses / algorithms - -print() -print("--- Create mesh on the box ...") -mesh = smesh.CreateMesh(box) -if salome.hasDesktop(): - smeshgui.SetName( salome.ObjectToID(mesh), "MeshBox" ); -ret = mesh.AddHypothesis(box, algoReg) -ret = mesh.AddHypothesis(box, algoMef) -ret = mesh.AddHypothesis(box, hypNbSeg1) -ret = mesh.AddHypothesis(box, hypArea1) -print("OK") - -# ---- create submesh on the edge, add hypothesis - -print() -print("--- Add 1D sub-mesh on the edge ...") -submesh = mesh.GetSubMesh(edge, "SubMeshEdge") -ret = mesh.AddHypothesis(edge, algoReg) -ret = mesh.AddHypothesis(edge, hypLen1) -print("OK") - -# ---- create submesh on the edge, add hypothesis - -print() -print("--- Add 2D sub-mesh on the face ...") -submesh = mesh.GetSubMesh(face, "SubMeshFace") -ret = mesh.AddHypothesis(face, hypArea2) -print("OK") - -# ---- compute mesh -print() -print("--- Compute mesh ...") -smesh.Compute(mesh, box) -print("OK") - -# ---- update object browser -if salome.hasDesktop(): - salome.sg.updateObjBrowser(); - -print() - -print("======================================================================") -print(" %d. Test Fields " % step); step+=1 -print("======================================================================") - -import medcalc -#from medcalc import properties -from medcalc.fieldproxy import FieldProxy - -medcalc.medconsole.setConsoleGlobals(globals()) -try: - med_root=os.environ["FIELDS_ROOT_DIR"] -except KeyError as e: - raise RuntimeError("FIELDS_ROOT_DIR should be defined to load the test data") - -filepath = os.path.join(med_root,"share","salome","resources","fields","medcalc_testfiles","smallmesh_varfield.med") -medcalc.medio.LoadDataSource(filepath) -fieldHandlerList = medcalc.medevents.dataManager.getFieldHandlerList() - -fieldHandler0 = fieldHandlerList[0] -print("---Field Handler 0:\n%s" % fieldHandler0) -fieldHandler1 = fieldHandlerList[1] -print("---Field Handler 1:\n%s" % fieldHandler1) - -print("--- The addition of two fields can be done using field handler directly.") -addFieldHandler = medcalc.fieldproxy.calculator.add(fieldHandler0,fieldHandler1) -print("--- Result handler:\n%s" % addFieldHandler) - -print("--- Or with a field proxy that easy the writing of operations.") -fieldProxy0 = FieldProxy(fieldHandler0) -fieldProxy1 = FieldProxy(fieldHandler1) - -resHandler = fieldProxy0 + fieldProxy1 -if resHandler is None: - print("Error: result handler is None!") -else: - print("--- Result handler:\n%s" % resHandler) - print("OK") - -print() - - -print("======================================================================") -print(" %d. Test Paravis " % step); step+=1 -print("======================================================================") - -if salome.hasDesktop(): # in gui mode - - print("**** Importing pvserver... It can take some time.") - import pvsimple as pvs - - #====================Stage1: Importing MED file==================== - - print("**** Stage1: Importing MED file") - - med_file = "ResOK_0000.med" - print("Import '{}'...............".format(med_file), end=' ') - path = os.path.join(os.getenv('DATA_DIR'), 'MedFiles', med_file) - med_reader = pvs.MEDReader(FileName=path) - if med_reader is None: - print("FAILED") - else: - print("OK") - times = med_reader.TimestepValues.GetData() - - #====================Stage2: Displaying presentation=============== - - print("**** Stage2: Displaying presentation") - - # ----------------------------------------------------------------- - print('Get view...................', end=' ') - view = pvs.GetRenderView() - if view is None: - print("FAILED") - else: - print("OK") - view.ResetCamera() - - # ----------------------------------------------------------------- - print("Show mesh..................", end=' ') - mesh = pvs.Show(med_reader, view) - view.ResetCamera() - if mesh is None: - print("FAILED") - else: - print("OK") - mesh.Representation = 'Surface With Edges' - pvs.Render(view) - time.sleep(1) - - # ----------------------------------------------------------------- - print("Show scalar map............", end=' ') - scalar_map = mesh - if scalar_map is None: - print("FAILED") - else: - print("OK") - scalar_map.Representation = 'Surface' - pvs.ColorBy(scalar_map, ('POINTS', 'vitesse', 'Magnitude')) - #scalar_map.SetScalarBarVisibility(view, True) - view.ViewTime = times[-1] - pvs.Render(view) - time.sleep(1) - scalar_map.Visibility = 0 - pvs.Render(view) - - # ----------------------------------------------------------------- - print("Show vectors...............", end=' ') - calc = pvs.Calculator(Input=med_reader) - calc.ResultArrayName = 'vitesse_3c' - calc.Function = 'iHat * vitesse_X + jHat * vitesse_Y + kHat * 0' - glyph = pvs.Glyph(Input=calc, GlyphType='Arrow') - glyph.OrientationArray = ['POINTS', 'vitesse_3c'] - glyph.ScaleArray = ['POINTS', 'No scale array'] - glyph.MaximumGlyphSize = 0.01 - vectors = pvs.Show(glyph, view) - if vectors is None: - print("FAILED") - else: - print("OK") - vectors.Representation = 'Surface' - pvs.Render(view) - time.sleep(1) - vectors.Visibility = 0 - pvs.Render(view) - - # ----------------------------------------------------------------- - print("Show iso surfaces..........", end=' ') - merge_blocks = pvs.MergeBlocks(Input=med_reader) - calc = pvs.Calculator(Input=merge_blocks) - calc.ResultArrayName = 'vitesse_magnitude' - calc.Function = 'sqrt(vitesse_X^2+vitesse_Y^2)' - data_range = med_reader.GetPointDataInformation()['vitesse'].GetComponentRange(-1) - nb_surfaces = 10 - surfaces = [data_range[0] + i*(data_range[1]-data_range[0])/(nb_surfaces-1) for i in range(nb_surfaces)] - contour = pvs.Contour(Input=calc) - contour.ComputeScalars = 1 - contour.ContourBy = ['POINTS', 'vitesse_magnitude'] - contour.Isosurfaces = surfaces - iso_surfaces = pvs.Show(contour, view) - if iso_surfaces is None: - print("FAILED") - else: - print("OK") - iso_surfaces.Representation = 'Surface' - pvs.ColorBy(iso_surfaces, ('POINTS', 'vitesse', 'Magnitude')) - pvs.Render(view) - time.sleep(1) - iso_surfaces.Visibility = 0 - pvs.Render(view) - - # ----------------------------------------------------------------- - print("Show cut planes............", end=' ') - slice = pvs.Slice(Input=med_reader) - slice.SliceType = "Plane" - slice.SliceType.Normal = [1.0, 0.0, 0.0] - bounds = med_reader.GetDataInformation().GetBounds() - nb_planes = 30 - displacement = 0.5 - b_left = bounds[0] + (bounds[1]-bounds[0])*displacement/100 - b_right = bounds[1] - (bounds[1]-bounds[0])*displacement/100 - b_range = b_right - b_left - positions = [b_left + i*b_range/(nb_planes-1) for i in range(nb_planes)] - slice.SliceOffsetValues = positions - pvs.Hide3DWidgets(proxy=slice.SliceType) - cut_planes = pvs.Show(slice, view) - if cut_planes is None: - print("FAILED") - else: - print("OK") - cut_planes.Representation = 'Surface' - pvs.ColorBy(cut_planes, ('POINTS', 'vitesse', 'Magnitude')) - pvs.Render(view) - time.sleep(1) - cut_planes.Visibility = 0 - pvs.Render(view) - - # ----------------------------------------------------------------- - print("Show deformed shape........", end=' ') - merge_blocks = pvs.MergeBlocks(Input=med_reader) - calc = pvs.Calculator(Input=merge_blocks) - calc.ResultArrayName = 'vitesse_3c' - calc.Function = 'iHat * vitesse_X + jHat * vitesse_Y + kHat * 0' - warp = pvs.WarpByVector(Input=calc) - warp.Vectors = ['POINTS', 'vitesse_3c'] - warp.ScaleFactor = 0.5 - deformed_shape = pvs.Show(warp, view) - if deformed_shape is None: - print("FAILED") - else: - print("OK") - deformed_shape.Representation = 'Surface' - pvs.ColorBy(deformed_shape, ('CELLS', 'pression')) - pvs.Render(view) - time.sleep(1) - deformed_shape.Visibility = 0 - pvs.Render(view) - -else: # not in gui mode, Paravis can not be tested - - print() - print("PARAVIS module requires SALOME to be running in GUI mode.") - print() - print("Skipping test for PARAVIS...") - pass - -# ---- update object browser -if salome.hasDesktop(): - salome.sg.updateObjBrowser(); +import unittest + +def main(modules=None): + suite = unittest.TestSuite() + loader = unittest.defaultTestLoader + + import salome + salome.salome_init() + + if not modules: + from salome.kernel.services import getComponentList + modules = getComponentList() + if salome.hasDesktop(): + import SalomePyQt + sg = SalomePyQt.SalomePyQt() + gui_modules = sg.getComponents() + modules += [i for i in gui_modules if i not in modules] + elif not isinstance(modules, (list, tuple)): + modules = [modules] + for module in modules: + test_name = '{}_test'.format(module.lower()) + try: + __import__(test_name) + test_module = sys.modules[test_name] + suite.addTest(loader.loadTestsFromModule(test_module)) + except ImportError: + pass + runner = unittest.TextTestRunner() + return runner.run(suite) + +main() diff --git a/src/Launcher/Test/test_stress.sh b/src/Launcher/Test/test_stress.sh index 88505fab8..97acc5d61 100755 --- a/src/Launcher/Test/test_stress.sh +++ b/src/Launcher/Test/test_stress.sh @@ -4,14 +4,16 @@ WORKDIR=`mktemp -d` echo WORKDIR: $WORKDIR cat > $WORKDIR/command.sh <<< 'echo "OK" > result.txt' chmod 755 $WORKDIR/command.sh +pid_launcher='' for i in {1..500} do python launcher_use_case.py $WORKDIR 2> $WORKDIR/log$i.err & + pid_launcher=$pid_launcher" "$! done exit_code=0 -for i in {1..500} +for i in "$pid_launcher" do - wait -n + wait $i ret=$? if [ $ret -ne "0" ] then diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx index 9924f6687..6fd8da5f6 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx @@ -390,51 +390,43 @@ SALOME_ModuleCatalogImpl::GetComputerList() // Function : GetPathPrefix // Purpose : get the PathPrefix of a computer //---------------------------------------------------------------------- -char * +char* SALOME_ModuleCatalogImpl::GetPathPrefix(const char* machinename) { if(MYDEBUG) MESSAGE("Begin of GetPathPrefix"); // Variables initialisation - char* _path = NULL; - bool _find = false ; + std::string _path; + bool _find = false; // Parse all the path prefixes // looking for the wanted computer - for (unsigned int ind = 0 ; ind < myPrivate->_personal_path_list.size() ; ind++) + for (unsigned int ind = 0; ind < myPrivate->_personal_path_list.size() && !_find; ind++) + { + for (unsigned int ind1 = 0; ind1 < myPrivate->_personal_path_list[ind].listOfComputer.size() && !_find; ind1++) { - for (unsigned int ind1 = 0 ; ind1 < myPrivate->_personal_path_list[ind].listOfComputer.size() ; ind1++) - { - if (strcmp(machinename, myPrivate->_personal_path_list[ind].listOfComputer[ind1].c_str()) == 0) - { - _find = true ; - // Wanted computer - // affect the path to be returned - const char* _temp = myPrivate->_personal_path_list[ind].path.c_str() ; - _path = new char[strlen(_temp)+1]; - strcpy(_path,_temp); - } - } + if ( myPrivate->_personal_path_list[ind].listOfComputer[ind1] == machinename ) + { + _find = true; + // Wanted computer + // affect the path to be returned + _path = myPrivate->_personal_path_list[ind].path; + } } + } - if (!_find) + for (unsigned int ind = 0; ind < myPrivate->_general_path_list.size() && !_find; ind++) + { + for (unsigned int ind1 = 0; ind1 < myPrivate->_general_path_list[ind].listOfComputer.size() && !_find; ind1++) { - for (unsigned int ind = 0 ; ind < myPrivate->_general_path_list.size() ; ind++) + if (myPrivate->_general_path_list[ind].listOfComputer[ind1] == machinename) { - for (unsigned int ind1 = 0 ; ind1 < myPrivate->_general_path_list[ind].listOfComputer.size() ; ind1++) - { - if (strcmp(machinename, myPrivate->_general_path_list[ind].listOfComputer[ind1].c_str()) == 0) - { - _find = true ; - // Wanted computer - // affect the path to be returned - const char* _temp = myPrivate->_general_path_list[ind].path.c_str() ; - _path = new char[strlen(_temp)+1]; - strcpy(_path,_temp); - } - } + _find = true; + // Wanted computer + // affect the path to be returned + _path = myPrivate->_general_path_list[ind].path; } } - - return _path; + } + return CORBA::string_dup(_path.c_str()) ; } //---------------------------------------------------------------------- diff --git a/src/ModuleGenerator/IDLparser.py b/src/ModuleGenerator/IDLparser.py index b2107353a..1734db43e 100644 --- a/src/ModuleGenerator/IDLparser.py +++ b/src/ModuleGenerator/IDLparser.py @@ -21,12 +21,10 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -# File : IDLparser.py -# Module : SALOME - -import string, sys, fpformat, re, os +import os +import os.path as osp +import re import xml.sax -import pdb from xml.sax.handler import * from omniidl import idlast, idltype, idlvisitor, idlutil, output @@ -116,7 +114,7 @@ class Tree: def output_xml(self, f, depth=0): d = depth if self.name != '': - s = string.ljust('', 4*depth) + s = ''.ljust(4*depth) s += '<' + self.name for k,v in list(self.attrs.items()): s += ' ' + k + '="' + v + '"' @@ -135,7 +133,7 @@ class Tree: if self.name != '': s = '\n' if len(self.childs) > 0 : - s = string.ljust('', 4*depth) + s + s = ''.ljust(4*depth) + s f.write(s) def Dump(self, levels=-1, depth=0): @@ -143,7 +141,7 @@ class Tree: if levels == 0: return - s = string.ljust('', 4*depth) + s = ''.ljust(4*depth) print(s, self, self.content) for i in self.childs: i.Dump(levels-1, depth+1) @@ -540,7 +538,7 @@ class Catalog(ContentHandler, Tree): self.buffer = '' def endElement(self, name): - self.buffer = string.join(string.split(self.buffer), ' ') + self.buffer = ' '.join(self.buffer.split()) p = self.list[len(self.list)-1] p.content = self.buffer if name == 'component': @@ -752,6 +750,9 @@ class ModuleCatalogVisitor (idlvisitor.AstVisitor): def visitStringType(self, type): self.currentType = "string" + def visitWStringType(self, type): + self.currentType = "wstring" + def visitParameter(self, node): node.paramType().accept(self) if node.is_in(): @@ -837,7 +838,7 @@ def run(tree, args): #================================================== - if (os.path.exists(CatalogFileName)): + if (osp.exists(CatalogFileName)): print("Importing", CatalogFileName) C = Catalog(CatalogFileName) else: @@ -854,7 +855,7 @@ def run(tree, args): if remove_comp : C.removeComponent(remove_comp) - if (os.path.exists(CatalogFileName)): + if (osp.exists(CatalogFileName)): print("Updating", CatalogFileName) CatalogFileName_old = CatalogFileName + '_old' os.rename(CatalogFileName, CatalogFileName_old) @@ -869,7 +870,7 @@ def run(tree, args): f.close() os.rename(CatalogFileName_new, CatalogFileName) - if ((CatalogFileName_old != "") & os.path.exists(CatalogFileName_old)): + if ((CatalogFileName_old != "") & osp.exists(CatalogFileName_old)): os.unlink(CatalogFileName_old) print() diff --git a/src/SALOMEDS/SALOME_DriverPy.py b/src/SALOMEDS/SALOME_DriverPy.py index 9757721b6..1b6d96b10 100644 --- a/src/SALOMEDS/SALOME_DriverPy.py +++ b/src/SALOMEDS/SALOME_DriverPy.py @@ -41,7 +41,7 @@ class SALOME_DriverPy_i(SALOMEDS__POA.Driver): return theSObject.GetID() def LocalPersistentIDToIOR(self, theSObject, PersistentID, isMultiFile, isASCII): - return "" + return '' def ComponentDataType(self): return self._ComponentDataType @@ -50,10 +50,10 @@ class SALOME_DriverPy_i(SALOMEDS__POA.Driver): try: return self.getVersion() except: - return "" + return '' def Save(self, theComponent, theURL, isMultiFile): - return "" + return b'' def SaveASCII(self, theComponent, theURL, isMultiFile): return self.Save(theComponent, theURL, isMultiFile) @@ -74,5 +74,13 @@ class SALOME_DriverPy_i(SALOMEDS__POA.Driver): return None def CanCopy(self, theObject): - return 0 + return False + def CopyFrom(theObject, theObjectID): + return b'' + + def CanPaste(theComponentName, theObjectID): + return False + + def PasteInto(theStream, theObjectID, theObject): + return None