Skip to content
Permalink
Browse files

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

… python
  • Loading branch information...
wwmayer committed Jun 13, 2019
1 parent 1b26173 commit 1406c03d186108c361b1a838852c68ba4946c71b
Showing with 17 additions and 2 deletions.
  1. +4 −2 src/App/Application.cpp
  2. +1 −0 src/Main/MainCmd.cpp
  3. +1 −0 src/Main/MainGui.cpp
  4. +11 −0 src/Main/MainPy.cpp
@@ -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();

0 comments on commit 1406c03

Please sign in to comment.
You can’t perform that action at this time.