Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenFlipper-Free
OpenFlipper
Commits
2a804285
Commit
2a804285
authored
Feb 01, 2019
by
Jan Möbius
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Documentation pages to the Python Widget
parent
a868603e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
8 deletions
+61
-8
PythonInterpreter/PyLogHook.h
PythonInterpreter/PyLogHook.h
+1
-1
PythonInterpreter/PythonInterpreter.cc
PythonInterpreter/PythonInterpreter.cc
+25
-5
PythonInterpreter/PythonInterpreter.hh
PythonInterpreter/PythonInterpreter.hh
+17
-0
cmake/plugin.cmake
cmake/plugin.cmake
+1
-2
widgets/pythonWidget/pythonWidget.cc
widgets/pythonWidget/pythonWidget.cc
+17
-0
No files found.
PythonInterpreter/PyLogHook.h
View file @
2a804285
//MIT License
//MIT License
//
//
//Copyright(c) 2017 Matthias Möller
//Copyright(c) 2017 Matthias M
�
ller
//https://github.com/TinyTinni/PyLogHook
//https://github.com/TinyTinni/PyLogHook
//
//
//Permission is hereby granted, free of charge, to any person obtaining a copy
//Permission is hereby granted, free of charge, to any person obtaining a copy
...
...
PythonInterpreter/PythonInterpreter.cc
View file @
2a804285
...
@@ -80,7 +80,9 @@ PythonInterpreter* PythonInterpreter::getInstance() {
...
@@ -80,7 +80,9 @@ PythonInterpreter* PythonInterpreter::getInstance() {
}
}
PythonInterpreter
::
PythonInterpreter
()
{
PythonInterpreter
::
PythonInterpreter
()
:
externalLogging_
(
false
)
{
}
}
...
@@ -213,19 +215,37 @@ bool PythonInterpreter::runScript(QString _script) {
...
@@ -213,19 +215,37 @@ bool PythonInterpreter::runScript(QString _script) {
return
result
;
return
result
;
}
}
QString
PythonInterpreter
::
runScriptOutput
(
QString
_script
)
{
LogOut
.
clear
();
LogErr
.
clear
();
externalLogging_
=
false
;
runScript
(
_script
);
externalLogging_
=
true
;
return
LogOut
+
LogErr
;
LogOut
.
clear
();
LogErr
.
clear
();
}
// Python callback functions
// Python callback functions
void
PythonInterpreter
::
pyOutput
(
const
char
*
w
)
void
PythonInterpreter
::
pyOutput
(
const
char
*
w
)
{
{
std
::
cerr
<<
"Python output:
\n
"
<<
w
<<
std
::
endl
;
if
(
externalLogging_
)
{
Q_EMIT
log
(
LOGOUT
,
QString
(
w
));
std
::
cerr
<<
"Python output:
\n
"
<<
w
<<
std
::
endl
;
Q_EMIT
log
(
LOGOUT
,
QString
(
w
));
}
else
{
LogOut
+=
QString
::
fromUtf8
(
w
);
}
}
}
void
PythonInterpreter
::
pyError
(
const
char
*
w
)
void
PythonInterpreter
::
pyError
(
const
char
*
w
)
{
{
std
::
cerr
<<
"Python error:
\n
"
<<
w
<<
std
::
endl
;
if
(
externalLogging_
)
{
Q_EMIT
log
(
LOGERR
,
QString
(
w
));
std
::
cerr
<<
"Python error:
\n
"
<<
w
<<
std
::
endl
;
Q_EMIT
log
(
LOGERR
,
QString
(
w
));
}
else
{
LogErr
+=
QString
::
fromUtf8
(
w
);
}
}
}
namespace
pybind11
{
namespace
detail
{
namespace
pybind11
{
namespace
detail
{
...
...
PythonInterpreter/PythonInterpreter.hh
View file @
2a804285
...
@@ -70,8 +70,21 @@ public:
...
@@ -70,8 +70,21 @@ public:
*/
*/
static
PythonInterpreter
*
getInstance
();
static
PythonInterpreter
*
getInstance
();
/** \brief Run a script. Output is passed to the standard logging facilities of OpenFlipper
*
* @param _script
* @return
*/
bool
runScript
(
QString
_script
);
bool
runScript
(
QString
_script
);
/** \ brief run a script and return the output as a QString
*
* @param _script
* @return
*/
QString
runScriptOutput
(
QString
_script
);
private:
private:
/** \brief private constructor because of singleton
/** \brief private constructor because of singleton
...
@@ -105,6 +118,10 @@ private:
...
@@ -105,6 +118,10 @@ private:
void
pyError
(
const
char
*
w
);
void
pyError
(
const
char
*
w
);
private:
bool
externalLogging_
;
QString
LogErr
;
QString
LogOut
;
};
};
/** \brief give Core pointer to PythonInterpreter for exporting of Core functionality to python
/** \brief give Core pointer to PythonInterpreter for exporting of Core functionality to python
...
...
cmake/plugin.cmake
View file @
2a804285
...
@@ -647,7 +647,6 @@ function (_build_openflipper_plugin plugin)
...
@@ -647,7 +647,6 @@ function (_build_openflipper_plugin plugin)
acg_append_files
(
sources
"*.cc"
PythonInterface
)
acg_append_files
(
sources
"*.cc"
PythonInterface
)
link_directories
(
${
Python3_LIBRARY_DIRS
}
)
link_directories
(
${
Python3_LIBRARY_DIRS
}
)
include_directories
(
${
Python3_INCLUDE_DIRS
}
)
include_directories
(
${
Python3_INCLUDE_DIRS
}
)
add_definitions
(
-DPYTHONINTERFACE_ENABLED
)
endif
()
endif
()
endif
()
endif
()
...
@@ -676,7 +675,7 @@ function (_build_openflipper_plugin plugin)
...
@@ -676,7 +675,7 @@ function (_build_openflipper_plugin plugin)
# Link plugin against python if possible
# Link plugin against python if possible
if
(
${
_PLUGIN
}
_PYTHONINTERFACE AND NOT DISABLE_OPENFLIPPER_PYTHON_SYSTEM
)
if
(
${
_PLUGIN
}
_PYTHONINTERFACE AND NOT DISABLE_OPENFLIPPER_PYTHON_SYSTEM
)
if
(
PYTHON3_FOUND
)
if
(
PYTHON3_FOUND
)
target_link_libraries
(
Plugin-
${
plugin
}
Python3::Python
)
target_link_libraries
(
Plugin-
${
plugin
}
pybind11::module pybind11::embed
Python3::Python
)
endif
()
endif
()
endif
()
endif
()
...
...
widgets/pythonWidget/pythonWidget.cc
View file @
2a804285
...
@@ -89,6 +89,23 @@ PythonWidget::PythonWidget(QWidget *parent )
...
@@ -89,6 +89,23 @@ PythonWidget::PythonWidget(QWidget *parent )
pythonInfo
->
append
(
" "
+
pythonPlugins
[
i
]
);
pythonInfo
->
append
(
" "
+
pythonPlugins
[
i
]
);
}
}
PythonInterpreter
*
interpreter
=
PythonInterpreter
::
getInstance
();
QTextEdit
*
coreInfo
=
new
QTextEdit
(
infoTab
);
infoTab
->
addTab
(
coreInfo
,
"Core"
);
QString
coreDoc
=
interpreter
->
runScriptOutput
(
"import pydoc ;import openflipper;html = pydoc.HTMLDoc();object, name = pydoc.resolve(openflipper);page = html.page(pydoc.describe(object), html.document(object, name));print(page)"
);
coreInfo
->
setHtml
(
coreDoc
);
// Collect all Python Documentation for the OpenFlipper Plugin Modules
for
(
int
i
=
0
;
i
<
pythonPlugins
.
size
()
;
++
i
)
{
QTextEdit
*
edit
=
new
QTextEdit
(
infoTab
);
infoTab
->
addTab
(
edit
,
pythonPlugins
[
i
]);
QString
data
=
interpreter
->
runScriptOutput
(
"import pydoc ;import "
+
pythonPlugins
[
i
]
+
";html = pydoc.HTMLDoc();object, name = pydoc.resolve("
+
pythonPlugins
[
i
]
+
");page = html.page(pydoc.describe(object), html.document(object, name));print(page)"
);
edit
->
setHtml
(
data
);
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment