From: boulant Date: Fri, 29 Mar 2013 13:28:26 +0000 (+0000) Subject: Padder execution error management (the errors are raised toward the gui) X-Git-Tag: V7_2_0b1~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1c3d4eccd17b112559ad4870a2a55a85f6a36b36;p=modules%2Fsmesh.git Padder execution error management (the errors are raised toward the gui) --- diff --git a/src/Tools/padder/meshjob/idl/MESHJOB.idl b/src/Tools/padder/meshjob/idl/MESHJOB.idl index 895fbd7cd..c10c8248f 100644 --- a/src/Tools/padder/meshjob/idl/MESHJOB.idl +++ b/src/Tools/padder/meshjob/idl/MESHJOB.idl @@ -76,7 +76,7 @@ module MESHJOB { string results_dirname; string outputmesh_filename; - string status; + boolean status; }; // This defines the possible states of a job diff --git a/src/Tools/padder/meshjob/impl/MeshJobManager_i.cxx b/src/Tools/padder/meshjob/impl/MeshJobManager_i.cxx index 76c71870e..5217c6c43 100644 --- a/src/Tools/padder/meshjob/impl/MeshJobManager_i.cxx +++ b/src/Tools/padder/meshjob/impl/MeshJobManager_i.cxx @@ -294,9 +294,9 @@ CORBA::Long MeshJobManager_i::initialize(const MESHJOB::MeshJobParameterList & m break; default: _lastErrorMessage = - std::string("The type of the file ")+ - std::string(currentMesh.file_name)+ - std::string(" is not recognized"); + std::string("The type of the file ")+ + std::string(currentMesh.file_name)+ + std::string(" is not recognized"); LOG(_lastErrorMessage); return JOBID_UNDEFINED; } @@ -569,18 +569,28 @@ MESHJOB::MeshJobResults * MeshJobManager_i::finalize(CORBA::Long jobId) { rename((local_resultdir+"/"+OUTPUTFILE).c_str(), (local_resultdir+"/"+outputFileName).c_str()); result->outputmesh_filename = outputFileName.c_str(); - result->status = "OK"; + + if ( fexists( (local_resultdir+"/"+outputFileName).c_str() ) != true ) { + _lastErrorMessage = std::string("The result file ")+ + std::string((local_resultdir+"/"+outputFileName).c_str())+ + std::string(" has not been created."); + result->status = false; + } + else { + result->status = true; + } } catch (const SALOME::SALOME_Exception & ex) { - LOG("SALOME Exception in getResults !"); - result->status = "SALOME Exception in getResults !"; _lastErrorMessage = ex.details.text.in(); + LOG(_lastErrorMessage); + result->status = false; } catch (const CORBA::SystemException& ex) { - LOG("Receive CORBA System Exception: " << ex); - result->status = "Receive CORBA System Exception: see log"; + _lastErrorMessage = "The SALOME launcher can not retrieve the result data"; + LOG(_lastErrorMessage); + result->status = false; } endService("MeshJobManager_i::getResults"); return result; diff --git a/src/Tools/padder/meshjob/impl/MeshJobManager_i.hxx b/src/Tools/padder/meshjob/impl/MeshJobManager_i.hxx index 40e2a96ce..f53d7aa34 100644 --- a/src/Tools/padder/meshjob/impl/MeshJobManager_i.hxx +++ b/src/Tools/padder/meshjob/impl/MeshJobManager_i.hxx @@ -42,9 +42,9 @@ public: ~MeshJobManager_i(); bool configure (const char *configId, - const MESHJOB::ConfigParameter & configParameter); + const MESHJOB::ConfigParameter & configParameter); CORBA::Long initialize (const MESHJOB::MeshJobParameterList & meshJobParameterList, - const char *configId); + const char *configId); bool start (CORBA::Long jobId); char* getState (CORBA::Long jobId); MESHJOB::MeshJobResults * finalize(CORBA::Long jobId); diff --git a/src/Tools/padder/meshjob/impl/SPADDERPluginTester_i.hxx b/src/Tools/padder/meshjob/impl/SPADDERPluginTester_i.hxx index 6aa4c71ce..26a7416cd 100644 --- a/src/Tools/padder/meshjob/impl/SPADDERPluginTester_i.hxx +++ b/src/Tools/padder/meshjob/impl/SPADDERPluginTester_i.hxx @@ -33,8 +33,8 @@ class SPADDERPluginTester_i: { public: SPADDERPluginTester_i(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, - PortableServer::ObjectId * contId, - const char *instanceName, const char *interfaceName); + PortableServer::ObjectId * contId, + const char *instanceName, const char *interfaceName); virtual ~SPADDERPluginTester_i(); void demo(CORBA::Double a,CORBA::Double b,CORBA::Double& c); diff --git a/src/Tools/padder/spadderpy/configreader.py b/src/Tools/padder/spadderpy/configreader.py index ceacf543f..010540419 100644 --- a/src/Tools/padder/spadderpy/configreader.py +++ b/src/Tools/padder/spadderpy/configreader.py @@ -85,13 +85,22 @@ class ConfigReader: return TYPE_LOCAL return defaultType - def printConfig(config): print "PADDER CONFIGURATION:" print "\tconfig.resname = %s"%config.resname print "\tconfig.binpath = %s"%config.binpath print "\tconfig.envpath = %s"%config.envpath +def getPadderTestDir(config): + """ + This function returns the directory of the SpherePadder + installation, where the tests cases are located. This should be + used for test only. It makes the hypothesis that the binpath to + the executable program is a path of the executable program of a + complete installation of SpherePadder. + """ + testdir=os.path.join(os.path.abspath(os.path.dirname(config.binpath)),"tests") + return testdir # # ========================================================================= diff --git a/src/Tools/padder/spadderpy/gui/plugindialog.py b/src/Tools/padder/spadderpy/gui/plugindialog.py index e62d7fdad..a8164a38e 100644 --- a/src/Tools/padder/spadderpy/gui/plugindialog.py +++ b/src/Tools/padder/spadderpy/gui/plugindialog.py @@ -340,14 +340,14 @@ class PluginDialog(QDialog): return meshJobResults = jobManager.finalize(self.__jobid) - if state == "ERROR": - self.__log("ERR: jobid = "+str(self.__jobid)+" ended with error: "+meshJobResults.status) - self.__log("ERR: %s"%jobManager.getLastErrorMessage()) + logsdirname = os.path.join(meshJobResults.results_dirname, "logs") + if state == "ERROR" or meshJobResults.status is not True: + msgtemp = "ERR: jobid = %s ended with error: %s" + self.__log(msgtemp%(str(self.__jobid),jobManager.getLastErrorMessage())) + self.__log("ERR: see log files in %s"%logsdirname) return - logsdirname = os.path.join(meshJobResults.results_dirname, "logs") - self.__log("INF: jobid="+str(self.__jobid)+" ended normally : "+meshJobResults.status) - self.__log("INF: jobid="+str(self.__jobid)+" see log files in : "+logsdirname) + self.__log("INF: jobid=%s ended normally (see log files in %s)"%(str(self.__jobid),logsdirname)) medfilename = os.path.join(meshJobResults.results_dirname, meshJobResults.outputmesh_filename) diff --git a/src/Tools/padder/unittests/usecase_meshJobManager.py b/src/Tools/padder/unittests/usecase_meshJobManager.py index fadfd403f..236337c03 100644 --- a/src/Tools/padder/unittests/usecase_meshJobManager.py +++ b/src/Tools/padder/unittests/usecase_meshJobManager.py @@ -22,7 +22,9 @@ # This script illustrates the standard use case of the component # MeshJobManager from within a SALOME script. It could be used as a -# unit test of the component. +# unit test of the component. The typical procedure is: +# $ /runAppli -t +# $ /runSession /usecase_meshJobManager.py # # ======================================================================= @@ -32,7 +34,7 @@ import sys import os import time -from salome.smesh.spadder.configreader import ConfigReader, printConfig +from salome.smesh.spadder.configreader import ConfigReader, printConfig, getPadderTestDir configReader = ConfigReader() defaultConfig = configReader.getDefaultConfig() @@ -70,7 +72,15 @@ component.configure(configId,config) # for testing the component. The test function number corresponds to # the number of the test defined in the SpherePadder installation # directory. - +PADDERTESTDIR = getPadderTestDir(defaultConfig) +#PADDERTESTDIR = spadder.getTestPadderDataDir() +# +# WARN: the above instruction (spadder.getTestPadderDataDir()) +# localizes the PADDERTEST DIR using the PADDERDIR shell variable, +# while the previous one (getPadderTestDir) localizes this directory +# from data of the config (read from the configuration file +# padder.cfg). +# def test00_parameters(): """Test using a concrete mesh and a single steelbar mesh""" file_concrete=os.path.join(spadder.getTestDataDir(),"concrete.med") @@ -90,7 +100,7 @@ def test00_parameters(): def test01_parameters(): """One concrete mesh and two steelbar meshes""" - datadir = os.path.join(spadder.getTestPadderDataDir(),"test01") + datadir = os.path.join(PADDERTESTDIR,"test01") meshJobParameterList = [] medfile = os.path.join(datadir,"concrete.med") @@ -115,7 +125,7 @@ def test01_parameters(): def test02_parameters(): """One steelbar mesh only, without a concrete mesh""" - datadir = os.path.join(spadder.getTestPadderDataDir(),"test02") + datadir = os.path.join(PADDERTESTDIR,"test02") meshJobParameterList = [] medfile = os.path.join(datadir,"cadreef.med") @@ -127,7 +137,7 @@ def test02_parameters(): def test03_parameters(): """One concrete mesh only, without a steelbar mesh""" - datadir = os.path.join(spadder.getTestPadderDataDir(),"test03") + datadir = os.path.join(PADDERTESTDIR,"test03") meshJobParameterList = [] medfile = os.path.join(datadir,"concrete.med") @@ -209,4 +219,6 @@ else: print "OK: jobid = "+str(jobid)+" ended with state="+str(state) meshJobResults = component.finalize(jobid) print meshJobResults - print "You will find the results files in the directory:\n%s"%meshJobResults.results_dirname + if meshJobResults.status is not True: + print "ERR: the results are not OK: %s"%component.getLastErrorMessage() + print "ERR: see log files in %s"%meshJobResults.results_dirname