------------------------------------------------------------------------------
| 846 | |
| 847 | //------------------------------------------------------------------------------ |
| 848 | int 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 | //------------------------------------------------------------------------------ |
| 885 | void vtkPythonInterpreter::SetCaptureStdin(bool val) |
nothing calls this directly
no test coverage detected