From: Ovidiu Mircescu Date: Tue, 8 Oct 2019 14:07:00 +0000 (+0200) Subject: Fix available resources in no salome server mode. X-Git-Tag: V9_4_0rc1~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3f14c9a12f79582f67bf294a0b46fb7f234e4f88;p=tools%2Fydefx.git Fix available resources in no salome server mode. --- diff --git a/src/pydefx/configuration.py b/src/pydefx/configuration.py index 591b3e6..34efb55 100644 --- a/src/pydefx/configuration.py +++ b/src/pydefx/configuration.py @@ -51,6 +51,6 @@ def defaultWckey(resource="localhost"): def availableResources(): resManager = salome_proxy.getResourcesManager() - params = salome_proxy.createSalomeParameters().resource_required - params.can_launch_batch_jobs = True - return resManager.GetFittingResources(params) + params = salome_proxy.createSalomeParameters() + params.resource_required.can_launch_batch_jobs = True + return resManager.GetFittingResources(params.resource_required) diff --git a/src/pydefx/salome_proxy.py b/src/pydefx/salome_proxy.py index 9067760..a117bbb 100644 --- a/src/pydefx/salome_proxy.py +++ b/src/pydefx/salome_proxy.py @@ -30,7 +30,6 @@ def createSalomeParameters(): result.resource_required = salome.ResourceParameters() else: result = pylauncher.JobParameters_cpp() - result.resource_required = pylauncher.resourceParams() return result _resourceManager = None diff --git a/src/pyexample/CMakeLists.txt b/src/pyexample/CMakeLists.txt index f00a9b0..d61efb4 100644 --- a/src/pyexample/CMakeLists.txt +++ b/src/pyexample/CMakeLists.txt @@ -25,6 +25,7 @@ IF(SALOME_BUILD_TESTS) SET(TESTFILES test_insitu.py test_prescript.py + test_default.py ) INSTALL(FILES ${TESTFILES} DESTINATION ${LOCAL_TEST_DIR}) INSTALL(PROGRAMS runUnitTest.sh diff --git a/src/pyexample/runUnitTest.sh b/src/pyexample/runUnitTest.sh index fc4d6f1..d516d31 100755 --- a/src/pyexample/runUnitTest.sh +++ b/src/pyexample/runUnitTest.sh @@ -18,6 +18,6 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -python3 -m unittest test_insitu.py test_prescript.py +python3 -m unittest test_insitu.py test_prescript.py test_default.py ret=$? exit $ret diff --git a/src/pyexample/test_default.py b/src/pyexample/test_default.py new file mode 100644 index 0000000..fa0b6e7 --- /dev/null +++ b/src/pyexample/test_default.py @@ -0,0 +1,31 @@ +import unittest +import os +import time + +class TestYdefx(unittest.TestCase): + def test_errors(self): + """ + Test errors in study script. + """ + import pydefx + + myScript = pydefx.PyScript() + myScript.loadString("a=5") + self.assertIn("not accepted statement", myScript.getErrors()) + + myScript.loadString("n'importe quoi!") + self.assertIn("SyntaxError", myScript.getErrors()) + + myScript.loadString("") + self.assertIn("Function _exec not found", myScript.getErrors()) + + with self.assertRaises(pydefx.pyscript.PyScriptException): + mySample = myScript.CreateEmptySample() + + def test_availableResources(self): + import pydefx + lr = pydefx.configuration.availableResources() + self.assertIn('localhost', lr) + +if __name__ == '__main__': + unittest.main() diff --git a/src/pyexample/tests1.py b/src/pyexample/tests1.py index e2d5676..1ceb6af 100644 --- a/src/pyexample/tests1.py +++ b/src/pyexample/tests1.py @@ -23,3 +23,9 @@ print(myStudy.getProgress()) myStudy.launch() print(myStudy.getJobState()) print(myStudy.getProgress()) +myStudy.wait() +print(myStudy.getJobState()) +print(myStudy.getProgress()) +myStudy.getResult() +print(myStudy.sample) +print(myStudy.global_result)