Salome HOME
Allow dumper to set empty user-defined name for features
[modules/shaper.git] / src / ModelHighAPI / ModelHighAPI_Tools.cpp
index 8923fd6e13bf01788622a586a564361eccb44709..23f65ebc61497dc1e3c0066451243f2feb610068 100644 (file)
@@ -43,6 +43,9 @@
 
 #include <Events_InfoMessage.h>
 
+// Have to be included before std headers
+#include <Python.h>
+
 #include <algorithm>
 #include <iostream>
 
@@ -344,22 +347,25 @@ bool checkPythonDump()
   std::string anError = storeFeatures(
     aSession->moduleDocument()->kind(), aSession->moduleDocument(), aStore, false);
   if (!anError.empty()) {
-    Events_InfoMessage anError("checkPythonDump", anError);
-    anError.send();
+    Events_InfoMessage anErrorMsg(std::string("checkPythonDump"), anError);
+    anErrorMsg.send();
     return false;
   }
   // close all before importation of the script
   aSession->closeAll();
   // execute the dumped
-  Config_ModuleReader::loadScript("check_dump");
+  PyGILState_STATE gstate = PyGILState_Ensure(); /* acquire python thread */
+  PyObject* PyFileObject = PyFile_FromString("./check_dump.py", "r");
+  PyRun_SimpleFileEx(PyFile_AsFile(PyFileObject), "./check_dump.py", 1);
+  PyGILState_Release(gstate); /* release python thread */
 
   // compare with the stored data
   anError = storeFeatures(
     aSession->moduleDocument()->kind(), aSession->moduleDocument(), aStore, true);
   if (!anError.empty()) {
     std::cout<<anError<<std::endl;
-    Events_InfoMessage anError("checkPythonDump", anError);
-    anError.send();
+    Events_InfoMessage anErrorMsg(std::string("checkPythonDump"), anError);
+    anErrorMsg.send();
     return false;
   }