X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/12f90800104b06e819eb9a7c2cd6ffcaf2003e0a..90a6f5184efbee4252e015a82aecd296749bcad3:/lib/python/python.cpp diff --git a/lib/python/python.cpp b/lib/python/python.cpp index b5a7abbf..b7a4cf38 100644 --- a/lib/python/python.cpp +++ b/lib/python/python.cpp @@ -3,6 +3,7 @@ #undef _POSIX_C_SOURCE #define _POSIX_C_SOURCE 200112L extern "C" void init_enigma(); +extern "C" void eBaseInit(void); extern void bsodFatal(); #define SKIP_PART2 @@ -121,8 +122,10 @@ ePython::ePython() // Py_OptimizeFlag = 1; Py_Initialize(); - + PyEval_InitThreads(); + init_enigma(); + eBaseInit(); } ePython::~ePython() @@ -130,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; @@ -187,6 +200,11 @@ int ePython::call(ePyObject pFunc, ePyObject pArgs) } else { PyErr_Print(); + ePyObject FuncStr = PyObject_Str(pFunc); + ePyObject ArgStr = PyObject_Str(pArgs); + eDebug("(PyObject_CallObject(%s,%s) failed)", PyString_AS_STRING(FuncStr), PyString_AS_STRING(ArgStr)); + Py_DECREF(FuncStr); + Py_DECREF(ArgStr); bsodFatal(); } }