Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
OpenFlipper
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OpenFlipper-Free
OpenFlipper
Commits
6cfa86c0
Commit
6cfa86c0
authored
7 months ago
by
Daniel Savchenko
Browse files
Options
Downloads
Patches
Plain Diff
turn on logs in release modes
parent
997d8227
No related branches found
No related tags found
2 merge requests
!265
Mac fix
,
!264
Mac fix
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
PythonInterpreter/PythonInterpreter.cc
+36
-36
36 additions, 36 deletions
PythonInterpreter/PythonInterpreter.cc
with
36 additions
and
36 deletions
PythonInterpreter/PythonInterpreter.cc
+
36
−
36
View file @
6cfa86c0
...
@@ -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
)
{
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment