Replace Python std output only for GUI application and not for CLI
This commit is contained in:
parent
58da2ebbcc
commit
95de7d19cf
|
@ -343,15 +343,20 @@ const char* InterpreterSingleton::init(int argc,char *argv[])
|
|||
Py_Initialize();
|
||||
PySys_SetArgv(argc, argv);
|
||||
PythonStdOutput::init_type();
|
||||
PythonStdOutput* out = new PythonStdOutput();
|
||||
PySys_SetObject("stdout", out);
|
||||
PySys_SetObject("stderr", out);
|
||||
this->_global = PyEval_SaveThread();
|
||||
}
|
||||
|
||||
return Py_GetPath();
|
||||
}
|
||||
|
||||
void InterpreterSingleton::replaceStdOutput()
|
||||
{
|
||||
PyGILStateLocker locker;
|
||||
PythonStdOutput* out = new PythonStdOutput();
|
||||
PySys_SetObject("stdout", out);
|
||||
PySys_SetObject("stderr", out);
|
||||
}
|
||||
|
||||
int InterpreterSingleton::cleanup(void (*func)(void))
|
||||
{
|
||||
return Py_AtExit( func );
|
||||
|
|
|
@ -193,6 +193,7 @@ public:
|
|||
/// init the interpreter and returns the module search path
|
||||
const char* init(int argc,char *argv[]);
|
||||
int runCommandLine(const char *prompt);
|
||||
void replaceStdOutput();
|
||||
static InterpreterSingleton &Instance(void);
|
||||
static void Destruct(void);
|
||||
//@}
|
||||
|
|
|
@ -1403,6 +1403,7 @@ static void init_resources()
|
|||
void Application::initApplication(void)
|
||||
{
|
||||
try {
|
||||
Base::Interpreter().replaceStdOutput();
|
||||
initTypes();
|
||||
new Base::ScriptProducer( "FreeCADGuiInit", FreeCADGuiInit );
|
||||
init_resources();
|
||||
|
|
Loading…
Reference in New Issue
Block a user