fixes #0004000: Ability to suppress console output when running under python
This commit is contained in:
@@ -1536,8 +1536,10 @@ void Application::initConfig(int argc, char ** argv)
|
||||
|
||||
// Init console ===========================================================
|
||||
Base::PyGILStateLocker lock;
|
||||
_pConsoleObserverStd = new ConsoleObserverStd();
|
||||
Console().AttachObserver(_pConsoleObserverStd);
|
||||
if (mConfig["LoggingConsole"] == "1") {
|
||||
_pConsoleObserverStd = new ConsoleObserverStd();
|
||||
Console().AttachObserver(_pConsoleObserverStd);
|
||||
}
|
||||
if (mConfig["Verbose"] == "Strict")
|
||||
Console().UnsetConsoleMode(ConsoleSingleton::Verbose);
|
||||
|
||||
|
||||
@@ -82,6 +82,7 @@ int main( int argc, char ** argv )
|
||||
// Init phase ===========================================================
|
||||
// sets the default run mode for FC, starts with command prompt if not overridden in InitConfig...
|
||||
App::Application::Config()["RunMode"] = "Exit";
|
||||
App::Application::Config()["LoggingConsole"] = "1";
|
||||
|
||||
// Inits the Application
|
||||
App::Application::init(argc,argv);
|
||||
|
||||
@@ -187,6 +187,7 @@ int main( int argc, char ** argv )
|
||||
// sets the default run mode for FC, starts with gui if not overridden in InitConfig...
|
||||
App::Application::Config()["RunMode"] = "Gui";
|
||||
App::Application::Config()["Console"] = "0";
|
||||
App::Application::Config()["LoggingConsole"] = "1";
|
||||
|
||||
// Inits the Application
|
||||
#if defined (FC_OS_WIN32)
|
||||
|
||||
@@ -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