From: Andreas Monzner Date: Thu, 19 Jul 2007 10:33:22 +0000 (+0000) Subject: fix error handling X-Git-Tag: 2.6.0~2080 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/68794a76cf18bbf9fd6970bdce4e5074896129c7?hp=87a694395b1942209d18a8a1fc5105cb6ac3d754 fix error handling --- diff --git a/lib/dvb/dvb.cpp b/lib/dvb/dvb.cpp index fa15d662..4a6da016 100644 --- a/lib/dvb/dvb.cpp +++ b/lib/dvb/dvb.cpp @@ -248,12 +248,12 @@ void eDVBResourceManager::addAdapter(iDVBAdapter *adapter) } } -void eDVBResourceManager::setFrontendSlotInformations(ePyObject list) +PyObject *eDVBResourceManager::setFrontendSlotInformations(ePyObject list) { if (!PyList_Check(list)) { PyErr_SetString(PyExc_StandardError, "eDVBResourceManager::setFrontendSlotInformations argument should be a python list"); - return; + return NULL; } if ((unsigned int)PyList_Size(list) != m_frontend.size()) { @@ -261,14 +261,16 @@ void eDVBResourceManager::setFrontendSlotInformations(ePyObject list) sprintf(blasel, "eDVBResourceManager::setFrontendSlotInformations list size incorrect %d frontends avail, but %d entries in slotlist", m_frontend.size(), PyList_Size(list)); PyErr_SetString(PyExc_StandardError, blasel); - return; + return NULL; } int pos=0; for (eSmartPtrList::iterator i(m_frontend.begin()); i != m_frontend.end(); ++i) { ePyObject obj = PyList_GET_ITEM(list, pos++); - i->m_frontend->setSlotInfo(obj); + if (!i->m_frontend->setSlotInfo(obj)) + return NULL; } + Py_RETURN_NONE; } RESULT eDVBResourceManager::allocateFrontend(ePtr &fe, ePtr &feparm) diff --git a/lib/dvb/dvb.h b/lib/dvb/dvb.h index f36e6f67..38d18f78 100644 --- a/lib/dvb/dvb.h +++ b/lib/dvb/dvb.h @@ -210,7 +210,7 @@ public: #endif PSignal1 frontendUseMaskChanged; SWIG_VOID(RESULT) allocateRawChannel(eUsePtr &SWIG_OUTPUT, int slot_index); - void setFrontendSlotInformations(SWIG_PYOBJECT(ePyObject) list); + PyObject *setFrontendSlotInformations(SWIG_PYOBJECT(ePyObject) list); }; SWIG_TEMPLATE_TYPEDEF(ePtr, eDVBResourceManager); SWIG_EXTEND(ePtr, diff --git a/lib/dvb/frontend.cpp b/lib/dvb/frontend.cpp index 1906a8f4..8b214130 100644 --- a/lib/dvb/frontend.cpp +++ b/lib/dvb/frontend.cpp @@ -2135,7 +2135,7 @@ int eDVBFrontend::isCompatibleWith(ePtr &feparm) return 1; } -void eDVBFrontend::setSlotInfo(ePyObject obj) +bool eDVBFrontend::setSlotInfo(ePyObject obj) { ePyObject Id, Descr, Enabled; if (!PyTuple_Check(obj) || PyTuple_Size(obj) != 3) @@ -2148,14 +2148,13 @@ void eDVBFrontend::setSlotInfo(ePyObject obj) strcpy(m_description, PyString_AS_STRING(Descr)); m_slotid = PyInt_AsLong(Id); m_enabled = Enabled == Py_True; - // HACK.. the rotor workaround is neede for all NIMs with LNBP21 voltage regulator... m_need_rotor_workaround = !!strstr(m_description, "Alps BSBE1") || !!strstr(m_description, "Alps -S"); - eDebug("setSlotInfo for dvb frontend %d to slotid %d, descr %s, need rotorworkaround %s, enabled %s", m_dvbid, m_slotid, m_description, m_need_rotor_workaround ? "Yes" : "No", m_enabled ? "Yes" : "No" ); - return; + return true; arg_error: PyErr_SetString(PyExc_StandardError, - "eDVBFrontend::setSlotInfo must get a tuple with first param slotid and second param slot description"); + "eDVBFrontend::setSlotInfo must get a tuple with first param slotid, second param slot description and third param enabled boolean"); + return false; } diff --git a/lib/dvb/frontend.h b/lib/dvb/frontend.h index d2070e96..6bf36466 100644 --- a/lib/dvb/frontend.h +++ b/lib/dvb/frontend.h @@ -122,7 +122,7 @@ public: int isCompatibleWith(ePtr &feparm); int getDVBID() { return m_dvbid; } int getSlotID() { return m_slotid; } - void setSlotInfo(ePyObject obj); // get a tuple (slotid, slotdescr) + bool setSlotInfo(ePyObject obj); // get a tuple (slotid, slotdescr) int openFrontend(); int closeFrontend();