Salome HOME
Padder execution error management (the errors are raised toward the gui)
authorboulant <boulant>
Fri, 29 Mar 2013 13:28:26 +0000 (13:28 +0000)
committerboulant <boulant>
Fri, 29 Mar 2013 13:28:26 +0000 (13:28 +0000)
src/Tools/padder/meshjob/idl/MESHJOB.idl
src/Tools/padder/meshjob/impl/MeshJobManager_i.cxx
src/Tools/padder/meshjob/impl/MeshJobManager_i.hxx
src/Tools/padder/meshjob/impl/SPADDERPluginTester_i.hxx
src/Tools/padder/spadderpy/configreader.py
src/Tools/padder/spadderpy/gui/plugindialog.py
src/Tools/padder/unittests/usecase_meshJobManager.py

index 895fbd7cd0b5c162c6dc866328a2a22705dd83d8..c10c8248fc00e46e3938dbfed997f055b1e60c7c 100644 (file)
@@ -76,7 +76,7 @@ module MESHJOB
   {
     string results_dirname;
     string outputmesh_filename;
-    string status;
+    boolean status;
   };
 
   // This defines the possible states of a job
index 76c71870eb64e1e853c46dea32b8606c7886e8de..5217c6c436026165cf41cca0ecffefdfc3a220e0 100644 (file)
@@ -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;
index 40e2a96ce1d8cd4cef43d712264fee69e699ba05..f53d7aa34888ce4f4b12fa44e2a81a0b1719cfd2 100644 (file)
@@ -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);
index 6aa4c71cefee993cbe371ee9c520e57c42bcb271..26a7416cdf0d1f7bca6d97f1dbeb1b5a3c1ce77d 100644 (file)
@@ -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);
index ceacf543fbef327d28ed10e838eb9ef8466d2dc4..0105404194068b828bf75d507e619c0dc752f3e4 100644 (file)
@@ -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
 
 #
 # =========================================================================
index e62d7fdad5d5375c4fcb18c6af6ecfe3060a535c..a8164a38e21cd43fbd7c5c4124e780dba8e64c79 100644 (file)
@@ -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)
index fadfd403f99f3c05f699f8b8dbafab6fd45893a6..236337c036d52a95285885e1b32759910d8e1ee8 100644 (file)
@@ -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:
+# $ <appli>/runAppli -t
+# $ <appli>/runSession </path/to>/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