X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FInitializationPlugin%2FInitializationPlugin_PyInterp.cpp;h=57ef46d48b4c0e98a8363ed934e1eb2dd4884e1e;hb=97c06c5cd9fc736f9b5a1dacde369a9d7b5be703;hp=b7d591b29c184ac7dae0caed20b00afbcd46436d;hpb=a1baede8e41ab33d4d133cfa42f1fbafb50c8438;p=modules%2Fshaper.git diff --git a/src/InitializationPlugin/InitializationPlugin_PyInterp.cpp b/src/InitializationPlugin/InitializationPlugin_PyInterp.cpp index b7d591b29..57ef46d48 100644 --- a/src/InitializationPlugin/InitializationPlugin_PyInterp.cpp +++ b/src/InitializationPlugin/InitializationPlugin_PyInterp.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// Copyright (C) 2014-2019 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -12,10 +12,9 @@ // // 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 +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or -// email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include @@ -63,8 +62,7 @@ InitializationPlugin_PyInterp::positions(const std::string& theExpression, // prepare a context PyObject* aContext = PyDict_New(); - PyObject* aBuiltinModule = PyImport_AddModule("__builtin__"); - PyDict_SetItemString(aContext, "__builtins__", aBuiltinModule); + PyDict_SetItemString(aContext, "__builtins__", PyEval_GetBuiltins()); std::string anExpression = adjustExpression(theExpression); // extend aContext with variables @@ -229,6 +227,26 @@ bool InitializationPlugin_PyInterp::initContext() _local_context = PyDict_New(); Py_INCREF(_local_context); + // to avoid "help()" hang in the python console + const static char* aHelpTxt = "def help(): print(\"Available modules:\\n" + " salome.shaper.model : higher level access to features and data model\\n" + " BuildAPI : Build plugin features allowing to build shapes\\n" + " ConfigAPI : configuration management: preferences and XML properties\\n" + " ConstructionAPI : Construction plugin for auxiliary features creation\\n" + " EventsAPI : application events receiving and emitting manager\\n" + " ExchangeAPI : Exchange plugin with import/export features\\n" + " FeaturesAPI : Features plugin with general 3D features\\n" + " GeomAlgoAPI : geometrical algorithms\\n" + " GeomAPI : geometrical data structures\\n" + " GeomDataAPI : specific geometrical data structures stored in the data model\\n" + " ModelAPI : general low-level interface to access data model\\n" + " ModelHighAPI : general high-level interface to access data model\\n" + " ParametersAPI : Parameters plugin for parameters feature management\\n" + " PartSetAPI : PartSet plugin for management Parts features\\n" + " SketchAPI : Sketch plugin with all sketch features\")"; + + PyRun_SimpleString(aHelpTxt); + return PyRun_SimpleString("from math import *") == 0; }