diff options
Diffstat (limited to 'lib/python')
| -rw-r--r-- | lib/python/python.cpp | 10 | ||||
| -rw-r--r-- | lib/python/python.h | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/lib/python/python.cpp b/lib/python/python.cpp index ad029fb6..b7a4cf38 100644 --- a/lib/python/python.cpp +++ b/lib/python/python.cpp @@ -133,6 +133,16 @@ ePython::~ePython() Py_Finalize(); } +int ePython::execFile(const char *file) +{ + FILE *fp = fopen(file, "r"); + if (!fp) + return -ENOENT; + int ret = PyRun_SimpleFile(fp, file); + fclose(fp); + return ret; +} + int ePython::execute(const std::string &pythonfile, const std::string &funcname) { ePyObject pName, pModule, pDict, pFunc, pArgs, pValue; diff --git a/lib/python/python.h b/lib/python/python.h index 9edc50ad..f56d49bb 100644 --- a/lib/python/python.h +++ b/lib/python/python.h @@ -370,6 +370,7 @@ class ePython public: ePython(); ~ePython(); + int execFile(const char *file); int execute(const std::string &pythonfile, const std::string &funcname); static int call(ePyObject pFunc, ePyObject args); static ePyObject resolve(const std::string &pythonfile, const std::string &funcname); |
