BALL 1.5.0
|
#include <BALL/PYTHON/pyInterpreter.h>
Public Types | |
Type definitions | |
using | PathStrings = std::vector< String > |
Used to encode the individual paths appended to sys.path for dynamic loading of modules. | |
Static Public Member Functions | |
Initialization | |
static void | initialize () |
static void | finalize () |
static bool | isInitialized () |
static BALL_DEPRECATED void | setSysPath (const PathStrings &path_strings) |
static BALL_DEPRECATED const PathStrings & | getSysPath () |
static BALL_DEPRECATED bool | isValid () |
static BALL_DEPRECATED String | getStartupLog () |
Execution | |
static std::pair< bool, std::string > | run (const std::string &s) |
static BALL_DEPRECATED String | run (const String &s, bool &result) |
static BALL_DEPRECATED String | runFile (const String &filename) |
static bool | execute (const std::string &module, const std::string &func, const PyKernel::KeyValArgs ¶ms) |
static std::string | getErrorMessage () |
static BALL_DEPRECATED bool | execute (const QString &module, const QString &func, const QList< QPair< QString, QString > > ¶ms) |
Server | |
static std::unique_ptr< PyKernel > | kernel_ |
static std::unique_ptr< PyServer > | server_ |
static PathStrings | sys_path_ |
static void | startServer () |
static void | stopServer () |
static bool | serverIsRunning () |
Embedded Python interpreter. There's just one global instance of the interpreter, so all methods are static. The use of subinterpreters is not yet supported.
Definition at line 25 of file pyInterpreter.h.
using BALL::PyInterpreter::PathStrings = std::vector<String> |
Used to encode the individual paths appended to sys.path for dynamic loading of modules.
Definition at line 36 of file pyInterpreter.h.
|
static |
|
static |
Calls a single function from a given module.
module | a Python module |
func | a function from the given module |
params | function arguments as key-value pairs |
|
static |
Stop the interpreter. Deallocate all memory occupied by the interpreter (by calling Py_Finalize
).
|
static |
Returns the most recent error message emitted by the Python interpreter.
|
inlinestatic |
Definition at line 79 of file pyInterpreter.h.
|
inlinestatic |
Get the current (additional) paths added to sys.path
Definition at line 73 of file pyInterpreter.h.
|
static |
Initialize the interpreter. Initialize the interpreter (by calling Py_Initialize
) and load the modules sys
, site
, and BALL
. A second call to initialize
may be used to restart the intepreter. Upon start, the paths defined by setSysPath are added to sys.path. If your interpreter cannot load specific modules, add the location of your modules here.
|
inlinestatic |
Determine the interpreter state.
Definition at line 61 of file pyInterpreter.h.
|
inlinestatic |
Definition at line 76 of file pyInterpreter.h.
|
static |
Execute a string.
s | the string to run (may contain multiple lines with correct indentation) |
ok
indicating whether the execution was successful and res
representing the output of the interpreter (may also contain error messages)
|
static |
|
static |
Run a Python program from a file. If the file does not exist, or cannot be opened, an Exception::FileNotFound is thrown
file_name | the name of the program file |
|
inlinestatic |
Indicates whether a PyServer instance is currently running.
Definition at line 144 of file pyInterpreter.h.
|
inlinestatic |
Append additional search paths to sys.path upon initialization
Definition at line 67 of file pyInterpreter.h.
|
static |
Start a PyServer instance (if not already running) to allow remote execution of Python code, e.g., via the BALLView Jupyter kernel.
|
static |
Stops the PyServer (if running).
|
staticprotected |
Definition at line 148 of file pyInterpreter.h.
|
staticprotected |
Definition at line 149 of file pyInterpreter.h.
|
staticprotected |
Definition at line 150 of file pyInterpreter.h.