MCPcopy Create free account
hub / github.com/Kitware/VTK / RunSimpleString

Method RunSimpleString

Utilities/PythonInterpreter/vtkPythonInterpreter.cxx:848–882  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

846
847//------------------------------------------------------------------------------
848int vtkPythonInterpreter::RunSimpleString(const char* script)
849{
850 vtkPythonInterpreter::Initialize(1);
851 vtkPythonInterpreter::ConsoleBuffering = true;
852
853 // The embedded python interpreter cannot handle DOS line-endings, see
854 // http://sourceforge.net/tracker/?group_id=5470&atid=105470&func=detail&aid=1167922
855 std::string buffer = script ? script : "";
856 buffer.erase(std::remove(buffer.begin(), buffer.end(), '\r'), buffer.end());
857
858 // The cast is necessary because PyRun_SimpleString() hasn't always been const-correct
859 int pyReturn;
860 {
861 vtkPythonScopeGilEnsurer gilEnsurer;
862 pyReturn = PyRun_SimpleString(buffer.c_str());
863 }
864
865 vtkPythonInterpreter::ConsoleBuffering = false;
866 if (!vtkPythonInterpreter::StdErrBuffer.empty())
867 {
868 vtkOutputWindow::GetInstance()->DisplayErrorText(vtkPythonInterpreter::StdErrBuffer.c_str());
869 NotifyInterpreters(
870 vtkCommand::ErrorEvent, const_cast<char*>(vtkPythonInterpreter::StdErrBuffer.c_str()));
871 vtkPythonInterpreter::StdErrBuffer.clear();
872 }
873 if (!vtkPythonInterpreter::StdOutBuffer.empty())
874 {
875 vtkOutputWindow::GetInstance()->DisplayText(vtkPythonInterpreter::StdOutBuffer.c_str());
876 NotifyInterpreters(
877 vtkCommand::SetOutputEvent, const_cast<char*>(vtkPythonInterpreter::StdOutBuffer.c_str()));
878 vtkPythonInterpreter::StdOutBuffer.clear();
879 }
880
881 return pyReturn;
882}
883
884//------------------------------------------------------------------------------
885void vtkPythonInterpreter::SetCaptureStdin(bool val)

Callers

nothing calls this directly

Calls 11

NotifyInterpretersFunction · 0.85
InitializeFunction · 0.50
removeFunction · 0.50
eraseMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
c_strMethod · 0.45
emptyMethod · 0.45
DisplayErrorTextMethod · 0.45
clearMethod · 0.45
DisplayTextMethod · 0.45

Tested by

no test coverage detected