X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/6dcb75c26bbfec04b381bb99d75404f9fe50635d..76e5181cade262b86610dcc851bcb4452196ccdc:/lib/python/python.cpp diff --git a/lib/python/python.cpp b/lib/python/python.cpp index 8947bb3c..c5faeed4 100644 --- a/lib/python/python.cpp +++ b/lib/python/python.cpp @@ -3,7 +3,9 @@ #undef _POSIX_C_SOURCE #define _POSIX_C_SOURCE 200112L extern "C" void init_enigma(); -extern void bsodFatal(); +extern "C" void eBaseInit(void); +extern "C" void eConsoleInit(void); +extern void bsodFatal(const char *component); #define SKIP_PART2 #include @@ -42,7 +44,7 @@ ePyObject::operator PyObject*() if (m_file) eDebug("last modified in file %s line %d from %d to %d", m_file, m_line, m_from, m_to); - bsodFatal(); + bsodFatal("enigma2, refcnt"); } return 0; } @@ -55,7 +57,7 @@ void ePyObject::incref(const char *file, int line) if (m_file) eDebug("last modified in file %s line %d from %d to %d", m_file, m_line, m_from, m_to); - bsodFatal(); + bsodFatal("enigma2, refcnt"); } if (m_erased || m_ob->ob_refcnt <= 0) { @@ -64,7 +66,7 @@ void ePyObject::incref(const char *file, int line) if (m_file) eDebug("last modified in file %s line %d from %d to %d", m_file, m_line, m_from, m_to); - bsodFatal(); + bsodFatal("enigma2, refcnt"); } if (m_ob->ob_refcnt == 0x7FFFFFFF) { @@ -73,7 +75,7 @@ void ePyObject::incref(const char *file, int line) if (m_file) eDebug("last modified in file %s line %d from %d to %d", m_file, m_line, m_from, m_to); - bsodFatal(); + bsodFatal("enigma2, refcnt"); } m_file = file; m_line = line; @@ -90,7 +92,7 @@ void ePyObject::decref(const char *file, int line) if (m_file) eDebug("last modified in file %s line %d from %d to %d", m_file, m_line, m_from, m_to); - bsodFatal(); + bsodFatal("enigma2, refcnt"); } if (m_erased || m_ob->ob_refcnt <= 0) { @@ -99,7 +101,7 @@ void ePyObject::decref(const char *file, int line) if (m_file) eDebug("last modified in file %s line %d from %d to %d", m_file, m_line, m_from, m_to); - bsodFatal(); + bsodFatal("enigma2, refcnt"); } m_file = file; m_line = line; @@ -114,18 +116,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 +123,11 @@ ePython::ePython() // Py_OptimizeFlag = 1; Py_Initialize(); - + PyEval_InitThreads(); + init_enigma(); + eBaseInit(); + eConsoleInit(); } ePython::~ePython() @@ -142,6 +135,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,7 +202,12 @@ int ePython::call(ePyObject pFunc, ePyObject pArgs) } else { PyErr_Print(); - bsodFatal(); + 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(0); } } return res;