Skip to content
Snippets Groups Projects
Commit 6cfa86c0 authored by Daniel Savchenko's avatar Daniel Savchenko
Browse files

turn on logs in release modes

parent 997d8227
No related branches found
No related tags found
2 merge requests!265Mac fix,!264Mac fix
...@@ -104,44 +104,44 @@ bool PythonInterpreter::modulesInitialized() { ...@@ -104,44 +104,44 @@ bool PythonInterpreter::modulesInitialized() {
void PythonInterpreter::initPython() { void PythonInterpreter::initPython() {
if (Py_IsInitialized() ) { if (Py_IsInitialized() ) {
#ifdef PYTHON_DEBUG //#ifdef PYTHON_DEBUG
std::cerr << "Python already Initialized!" << std::endl; std::cerr << "Python already Initialized!" << std::endl;
#endif //#endif
return; return;
} }
#ifdef PYTHON_DEBUG //#ifdef PYTHON_DEBUG
std::cerr << "Initialize interpreter ... " ; std::cerr << "Initialize interpreter ... " ;
#endif //#endif
py::initialize_interpreter(); py::initialize_interpreter();
#ifdef PYTHON_DEBUG //#ifdef PYTHON_DEBUG
std::cerr << " Done" << std::endl; std::cerr << " Done" << std::endl;
std::cerr << "[PyInfo] Python " << Py_GetVersion() << std::endl; std::cerr << "[PyInfo] Python " << Py_GetVersion() << std::endl;
std::wcerr << "[PyInfo] Binary: " << Py_GetProgramFullPath() << std::endl; std::wcerr << "[PyInfo] Binary: " << Py_GetProgramFullPath() << std::endl;
std::wcerr << "[PyInfo] Path: " << Py_GetPath() << std::endl; std::wcerr << "[PyInfo] Path: " << Py_GetPath() << std::endl;
std::cerr << "Initialize Threads ..."; std::cerr << "Initialize Threads ...";
#endif //#endif
//PyEval_InitThreads(); //PyEval_InitThreads();
#ifdef PYTHON_DEBUG //#ifdef PYTHON_DEBUG
std::cerr << " Done" << std::endl; std::cerr << " Done" << std::endl;
#endif //#endif
if (!modulesInitialized()) { if (!modulesInitialized()) {
#ifdef PYTHON_DEBUG //#ifdef PYTHON_DEBUG
std::cerr << "Import __main__" ; std::cerr << "Import __main__" ;
#endif //#endif
//dlopen("libpython3.5m.so.1.0", RTLD_LAZY | RTLD_GLOBAL); //dlopen("libpython3.5m.so.1.0", RTLD_LAZY | RTLD_GLOBAL);
py::module* main = new py::module( py::module::import("__main__") ); py::module* main = new py::module( py::module::import("__main__") );
#ifdef PYTHON_DEBUG //#ifdef PYTHON_DEBUG
std::cerr << " Done" << std::endl; std::cerr << " Done" << std::endl;
std::cerr << "Redirect Outputs ..."; std::cerr << "Redirect Outputs ...";
#endif //#endif
// Redirect python output to integrated logger functions // Redirect python output to integrated logger functions
...@@ -151,27 +151,27 @@ void PythonInterpreter::initPython() { ...@@ -151,27 +151,27 @@ void PythonInterpreter::initPython() {
tyti::pylog::redirect_stdout([this](const char* w) {this->pyOutput(w); }); tyti::pylog::redirect_stdout([this](const char* w) {this->pyOutput(w); });
} }
#ifdef PYTHON_DEBUG //#ifdef PYTHON_DEBUG
std::cerr << " Done" << std::endl; std::cerr << " Done" << std::endl;
std::cerr << "Get __dict__ from main namespace ..."; std::cerr << "Get __dict__ from main namespace ...";
#endif //#endif
// ========================================================= // =========================================================
// Add OpenFlipper Core module to main namespace // Add OpenFlipper Core module to main namespace
// ========================================================= // =========================================================
py::object main_namespace = main->attr("__dict__"); py::object main_namespace = main->attr("__dict__");
#ifdef PYTHON_DEBUG //#ifdef PYTHON_DEBUG
std::cerr << " Done" << std::endl; std::cerr << " Done" << std::endl;
std::cerr << "Importing OpenFlipper core module ..."; std::cerr << "Importing OpenFlipper core module ...";
#endif //#endif
py::module of_module(py::module::import("openflipper")); py::module of_module(py::module::import("openflipper"));
main_namespace["openflipper"] = of_module; main_namespace["openflipper"] = of_module;
#ifdef PYTHON_DEBUG //#ifdef PYTHON_DEBUG
std::cerr << " Done" << std::endl; std::cerr << " Done" << std::endl;
#endif //#endif
// ========================================================= // =========================================================
// Import with python interface to main namespace // Import with python interface to main namespace
...@@ -181,43 +181,43 @@ void PythonInterpreter::initPython() { ...@@ -181,43 +181,43 @@ void PythonInterpreter::initPython() {
for ( int i = 0 ; i < pythonPlugins.size() ; ++i ) { for ( int i = 0 ; i < pythonPlugins.size() ; ++i ) {
#ifdef PYTHON_DEBUG //#ifdef PYTHON_DEBUG
std::cerr << "Importing "+ pythonPlugins[i].toStdString() + " module ..."; std::cerr << "Importing "+ pythonPlugins[i].toStdString() + " module ...";
#endif //#endif
py::module om_module(py::module::import(pythonPlugins[i].toStdString().c_str())); py::module om_module(py::module::import(pythonPlugins[i].toStdString().c_str()));
main_namespace[pythonPlugins[i].toStdString().c_str()] = om_module; main_namespace[pythonPlugins[i].toStdString().c_str()] = om_module;
#ifdef PYTHON_DEBUG //#ifdef PYTHON_DEBUG
std::cerr << " Done" << std::endl; std::cerr << " Done" << std::endl;
#endif //#endif
} }
#ifdef PYTHON_DEBUG //#ifdef PYTHON_DEBUG
std::cerr << "Copy dict ..."; std::cerr << "Copy dict ...";
#endif //#endif
global_dict_clean_ = PyDict_Copy(PyModule_GetDict(main->ptr())); global_dict_clean_ = PyDict_Copy(PyModule_GetDict(main->ptr()));
#ifdef PYTHON_DEBUG //#ifdef PYTHON_DEBUG
std::cerr << " Done" << std::endl; std::cerr << " Done" << std::endl;
std::cerr << "Set to validate state ..."; std::cerr << "Set to validate state ...";
#endif //#endif
// set the main module member to a validate state, shows, that all modules are successfully initialized // set the main module member to a validate state, shows, that all modules are successfully initialized
mainModule_ = main; mainModule_ = main;
#ifdef PYTHON_DEBUG //#ifdef PYTHON_DEBUG
std::cerr << " Done" << std::endl; std::cerr << " Done" << std::endl;
std::cerr << "Save thread ..."; std::cerr << "Save thread ...";
#endif //#endif
// Do not release the GIL until all modules are initalzed // Do not release the GIL until all modules are initalzed
PyEval_SaveThread(); PyEval_SaveThread();
#ifdef PYTHON_DEBUG //#ifdef PYTHON_DEBUG
std::cerr << " Done" << std::endl; std::cerr << " Done" << std::endl;
#endif //#endif
// ========================================================= // =========================================================
// Test for numpy // Test for numpy
...@@ -249,9 +249,9 @@ void PythonInterpreter::resetInterpreter() ...@@ -249,9 +249,9 @@ void PythonInterpreter::resetInterpreter()
bool PythonInterpreter::runScript(const QString& _script) { bool PythonInterpreter::runScript(const QString& _script) {
#ifdef PYTHON_DEBUG //#ifdef PYTHON_DEBUG
std::cerr << "runScript" << std::endl; std::cerr << "runScript" << std::endl;
#endif //#endif
//============================================================ //============================================================
// Prepend module instance getter to the script // Prepend module instance getter to the script
...@@ -271,15 +271,15 @@ bool PythonInterpreter::runScript(const QString& _script) { ...@@ -271,15 +271,15 @@ bool PythonInterpreter::runScript(const QString& _script) {
try try
{ {
#ifdef PYTHON_DEBUG //#ifdef PYTHON_DEBUG
std::cerr << "Initialize Python" << std::endl; std::cerr << "Initialize Python" << std::endl;
#endif //#endif
initPython(); initPython();
#ifdef PYTHON_DEBUG //#ifdef PYTHON_DEBUG
std::cerr << "Done initializing Python" << std::endl; std::cerr << "Done initializing Python" << std::endl;
#endif //#endif
} }
catch (py::error_already_set &e) catch (py::error_already_set &e)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment