fixes #0004000: Ability to suppress console output when running under python

This commit is contained in:
wmayer
2019-06-13 15:46:49 +02:00
parent 98a53884dc
commit fdcd36f251
4 changed files with 17 additions and 2 deletions

View File

@@ -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();