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