fixes #0004000: Ability to suppress console output when running under python
This commit is contained in:
@@ -42,10 +42,12 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
// FreeCAD Base header
|
||||
#include <Base/Exception.h>
|
||||
#include <Base/Sequencer.h>
|
||||
#include <App/Application.h>
|
||||
|
||||
|
||||
@@ -228,6 +230,15 @@ PyMOD_INIT_FUNC(FreeCAD)
|
||||
free(argv[0]);
|
||||
free(argv);
|
||||
|
||||
Base::EmptySequencer* seq = new Base::EmptySequencer();
|
||||
(void)seq;
|
||||
static Base::RedirectStdOutput stdcout;
|
||||
static Base::RedirectStdLog stdclog;
|
||||
static Base::RedirectStdError stdcerr;
|
||||
std::cout.rdbuf(&stdcout);
|
||||
std::clog.rdbuf(&stdclog);
|
||||
std::cerr.rdbuf(&stdcerr);
|
||||
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
//PyObject* module = _PyImport_FindBuiltin("FreeCAD");
|
||||
PyObject* modules = PyImport_GetModuleDict();
|
||||
|
||||
Reference in New Issue
Block a user