use another function to initial import mytest.py (this fixes python
[enigma2.git] / lib / python / python.cpp
index 8e9fbd7e18b1b1bbd46f9ecbb3f38c48394b1664..b7a4cf38251320313631fd6498abc9b176198b3f 100644 (file)
@@ -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
@@ -124,6 +125,7 @@ ePython::ePython()
        PyEval_InitThreads();
 
        init_enigma();
+       eBaseInit();
 }
 
 ePython::~ePython()
@@ -131,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;
@@ -188,7 +200,11 @@ int ePython::call(ePyObject pFunc, ePyObject pArgs)
                } else
                {
                        PyErr_Print();
-                       eDebug("(PyObject_CallObject failed)");
+                       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();
                }
        }