Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Stack Of Tasks
dynamic-graph-python
Commits
5bee2872
Commit
5bee2872
authored
Feb 11, 2011
by
Nicolas Mansard
Committed by
Nicolas Mansard
Feb 11, 2011
Browse files
Modify the "runFile" function that was not working, at create a new function to call for the shell.
parent
4562d981
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/dynamic-graph/python/interpreter.hh
View file @
5bee2872
...
...
@@ -44,6 +44,7 @@ namespace dynamicgraph {
/// \brief Method to exectue a python script.
/// \param filename the filename
void
runPythonFile
(
std
::
string
filename
);
void
runMain
(
void
);
/// \brief Process input stream to send relevant blocks to python
/// \param stream input stream
...
...
src/interpreter.cc
View file @
5bee2872
...
...
@@ -100,13 +100,20 @@ std::string Interpreter::python( const std::string& command )
void
Interpreter
::
runPythonFile
(
std
::
string
filename
)
{
Py_Finalize
();
Py_Initialize
();
PyRun_SimpleString
(
pythonPrefix
[
0
].
c_str
());
PyRun_SimpleString
(
pythonPrefix
[
1
].
c_str
());
PyRun_SimpleString
(
pythonPrefix
[
2
].
c_str
());
PyRun_SimpleString
(
pythonPrefix
[
4
].
c_str
());
PyRun_SimpleFile
(
NULL
,
filename
.
c_str
());
PyObject
*
pymainContext
=
globals_
;
PyRun_File
(
fopen
(
filename
.
c_str
(),
"r"
),
filename
.
c_str
(),
Py_file_input
,
pymainContext
,
pymainContext
);
if
(
PyErr_Occurred
())
{
std
::
cout
<<
"Error occures..."
<<
std
::
endl
;
PyErr_Print
();
}
}
void
Interpreter
::
runMain
(
void
)
{
const
char
*
argv
[]
=
{
"dg-embedded-pysh"
};
Py_Main
(
1
,
const_cast
<
char
**>
(
argv
));
}
std
::
string
Interpreter
::
processStream
(
std
::
istream
&
stream
,
std
::
ostream
&
os
)
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment