X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=blobdiff_plain;f=lib%2Fpython%2Fpython.cpp;h=b7a4cf38251320313631fd6498abc9b176198b3f;hp=8947bb3ca12826f63e0a4d811809c560ca705c63;hb=da9872eac33f4f8a085261c3cbdcbf4c8d664f65;hpb=6dcb75c26bbfec04b381bb99d75404f9fe50635d diff --git a/lib/python/python.cpp b/lib/python/python.cpp index 8947bb3..b7a4cf3 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 @@ -114,18 +115,6 @@ void ePyObject::decref(const char *file, int line) #include #undef SKIP_PART1 -DEFINE_REF(TestObj); - -TestObj::TestObj() -{ - eDebug("create %p", this); -} - -TestObj::~TestObj() -{ - eDebug("destroy %p", this); -} - ePython::ePython() { // Py_VerboseFlag = 1; @@ -133,8 +122,10 @@ ePython::ePython() // Py_OptimizeFlag = 1; Py_Initialize(); - + PyEval_InitThreads(); + init_enigma(); + eBaseInit(); } ePython::~ePython() @@ -142,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; @@ -199,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(); } }