import enigma
import xml.etree.cElementTree
-from keyids import KEYIDS;
+from keyids import KEYIDS
# these are only informational (for help)...
from Tools.KeyBindings import addKeyBinding
+class KeymapError(Exception):
+ def __init__(self, message):
+ self.message = message
+
+ def __str__(self):
+ return self.message
+
def parseKeys(context, filename, actionmap, device, keys):
for x in keys.findall("key"):
get_attr = x.attrib.get
elif id[1] == 'd':
keyid = int(id[2:]) | 0x8000
else:
- raise "key id '" + str(id) + "' is neither hex nor dec"
+ raise KeymapError("key id '" + str(id) + "' is neither hex nor dec")
else:
try:
keyid = KEYIDS[id]
except:
- raise "key id '" + str(id) + "' is illegal"
+ raise KeymapError("key id '" + str(id) + "' is illegal")
# print context + "::" + mapto + " -> " + device + "." + hex(keyid)
actionmap.bindKey(filename, device, keyid, flags, context, mapto)
addKeyBinding(filename, keyid, context, mapto, flags)
try:
dom = xml.etree.cElementTree.parse(source)
except:
- raise "keymap %s not well-formed." % filename
+ raise KeymapError("keymap %s not well-formed." % filename)
keymap = dom.getroot()
except:
pass
- raise "action enum must be simple."
+ raise Exception("action enum must be simple.")
counter = 0
if counter:
if t != ",":
- raise "no comma"
+ raise Exception("no comma")
t = tokens.next()
if firsthit:
ePyObject obj = PyTuple_GET_ITEM(arg,0);
if (PyString_Check(obj))
{
+#if PY_VERSION_HEX < 0x02060000
argcount = PyString_GET_SIZE(obj);
+#else
+ argcount = PyString_Size(obj);
+#endif
argstring = PyString_AS_STRING(obj);
for (int i=0; i < argcount; ++i)
switch(argstring[i])
{
int casetype = PyLong_AsLong(PyTuple_GET_ITEM(arg, 4));
const char *str = PyString_AS_STRING(obj);
+#if PY_VERSION_HEX < 0x02060000
int textlen = PyString_GET_SIZE(obj);
+#else
+ int textlen = PyString_Size(obj);
+#endif
if (querytype == 1)
eDebug("lookup for events with '%s' as title(%s)", str, casetype?"ignore case":"case sensitive");
else
from Converter import Converter
from Poll import Poll
from time import time
-from Components.Element import cached
+from Components.Element import cached, ElementError
class EventTime(Poll, Converter, object):
STARTTIME = 0
self.poll_interval = 30*1000
self.poll_enabled = True
else:
- raise str("'%s' is not <StartTime|EndTime|Remaining|Duration|Progress> for EventTime converter" % type)
+ raise ElementError("'%s' is not <StartTime|EndTime|Remaining|Duration|Progress> for EventTime converter" % type)
@cached
def getTime(self):
from Components.Converter.Converter import Converter
-from Components.Element import cached
+from Components.Element import cached, ElementError
from enigma import iServiceInformation
from ServiceReference import ServiceReference
elif type == "RecordServiceName":
self.type = self.MOVIE_REC_SERVICE_NAME
else:
- raise str("'%s' is not <ShortDescription|MetaDescription|RecordServiceName> for MovieInfo converter" % type)
+ raise ElementError("'%s' is not <ShortDescription|MetaDescription|RecordServiceName> for MovieInfo converter" % type)
Converter.__init__(self, type)
@cached
from Converter import Converter
from Poll import Poll
from enigma import iPlayableService
-from Components.Element import cached
+from Components.Element import cached, ElementError
class ServicePosition(Converter, Poll, object):
TYPE_LENGTH = 0
elif type == "Gauge":
self.type = self.TYPE_GAUGE
else:
- raise "type must be {Length|Position|Remaining|Gauge} with optional arguments {Negate|Detailed|ShowHours|NoSeconds}"
+ raise ElementError("type must be {Length|Position|Remaining|Gauge} with optional arguments {Negate|Detailed|ShowHours|NoSeconds}")
self.poll_enabled = self.type != self.TYPE_LENGTH
from Converter import Converter
-from Components.Element import cached
+from Components.Element import cached, ElementError
from enigma import iServiceInformation
class ServiceTime(Converter, object):
elif type == "Duration":
self.type = self.DURATION
else:
- raise str("'%s' is not <StartTime|EndTime|Duration> for eEventTime converter" % type)
+ raise ElementError("'%s' is not <StartTime|EndTime|Duration> for eEventTime converter" % type)
@cached
def getTime(self):
return cache[name][1]
return wrapper
+class ElementError(Exception):
+ def __init__(self, message):
+ self.message = message
+
+ def __str__(self):
+ return self.message
+
class Element(object):
CHANGED_DEFAULT = 0 # initial "pull" state
CHANGED_ALL = 1 # really everything changed
from time import localtime, mktime
from datetime import datetime
-from sets import Set
-
def getConfigSatlist(orbpos, satlist):
default_orbpos = None
for x in satlist:
def update(self):
sec = secClass.getInstance()
- self.configuredSatellites = Set()
+ self.configuredSatellites = set()
sec.clear() ## this do unlinking NIMs too !!
print "sec config cleared"
def __init__(self, nimmgr):
self.NimManager = nimmgr
- self.configuredSatellites = Set()
+ self.configuredSatellites = set()
self.update()
class NIM(object):
self.instance.writeText(eRect(l[1], l[2], l[3], l[4]), gRGB(l[5]), gRGB(l[6]), l[7], l[8], l[9])
else:
print "drawlist entry:", l
- raise "invalid drawlist entry"
+ raise RuntimeError("invalid drawlist entry")
def changed(self, what):
self.pull_updates()
def mycallback(self, answer):
print "answer:", answer
if answer:
- raise "test-crash"
+ raise Exception("test-crash")
self.close()
def keyLeft(self):
class ChannelContextMenu(Screen):
def __init__(self, session, csel):
Screen.__init__(self, session)
- #raise "we need a better summary screen here"
+ #raise Exception("we need a better summary screen here")
self.csel = csel
self.bsel = None
if recording.setAutoincreaseEnd():
self.session.nav.RecordTimer.record(recording)
self.recording.append(recording)
- self.session.open(MessageBox, _("Record time limited due to conflicting timer %s" % name_date), MessageBox.TYPE_INFO)
+ self.session.open(MessageBox, _("Record time limited due to conflicting timer %s") % name_date, MessageBox.TYPE_INFO)
else:
- self.session.open(MessageBox, _("Couldn't record due to conflicting timer %s" % name), MessageBox.TYPE_INFO)
+ self.session.open(MessageBox, _("Couldn't record due to conflicting timer %s") % name, MessageBox.TYPE_INFO)
recording.autoincrease = False
else:
self.recording.append(recording)
setupdom = xml.etree.cElementTree.parse(setupfile)
setupfile.close()
+class SetupError(Exception):
+ def __init__(self, message):
+ self.message = message
+
+ def __str__(self):
+ return self.message
+
class SetupSummary(Screen):
skin = """
<screen position="6,0" size="120,64">
for x in xmldata.findall("setup"):
if x.get("key") == id:
return x.get("title", "").encode("UTF-8")
- raise "unknown setup id '%s'!" % repr(id)
+ raise SetupError("unknown setup id '%s'!" % repr(id))
alpha = loadPNG(path + "a.png")
ptr = loadJPG(path + "rgb.jpg", alpha)
else:
- raise "neither .png nor .jpg, please fix file extension"
+ raise Exception("neither .png nor .jpg, please fix file extension")
if ptr and desktop:
desktop.makeCompatiblePixmap(ptr)
#ifdef PYTHON_REFCOUNT_DEBUG
inline ePyObject(PyObject *ob, const char *file, int line);
#endif
+ inline ePyObject(PyVarObject *ob);
inline ePyObject(PyDictObject *ob);
inline ePyObject(PyTupleObject *ob);
inline ePyObject(PyListObject *ob);
operator bool() { return !!m_ob; }
ePyObject &operator=(const ePyObject &);
ePyObject &operator=(PyObject *);
+ ePyObject &operator=(PyVarObject *ob) { return operator=((PyObject*)ob); }
ePyObject &operator=(PyDictObject *ob) { return operator=((PyObject*)ob); }
ePyObject &operator=(PyTupleObject *ob) { return operator=((PyObject*)ob); }
ePyObject &operator=(PyListObject *ob) { return operator=((PyObject*)ob); }
ePyObject &operator=(PyStringObject *ob) { return operator=((PyObject*)ob); }
operator PyObject*();
+ operator PyVarObject*() { return (PyVarObject*)operator PyVarObject*(); }
operator PyTupleObject*() { return (PyTupleObject*)operator PyObject*(); }
operator PyListObject*() { return (PyListObject*)operator PyObject*(); }
operator PyStringObject*() { return (PyStringObject*)operator PyObject*(); }
}
#endif
+inline ePyObject::ePyObject(PyVarObject *ob)
+ :m_ob((PyObject*)ob)
+#ifdef PYTHON_REFCOUNT_DEBUG
+ ,m_file(0), m_line(0), m_from(0), m_to(0), m_erased(false)
+#endif
+{
+}
+
inline ePyObject::ePyObject(PyDictObject *ob)
:m_ob((PyObject*)ob)
#ifdef PYTHON_REFCOUNT_DEBUG
def open(self, screen, *arguments, **kwargs):
if len(self.dialog_stack) and not self.in_exec:
- raise "modal open are allowed only from a screen which is modal!"
+ raise RuntimeError("modal open are allowed only from a screen which is modal!")
# ...unless it's the very first screen.
self.pushCurrent()
colorNames[name] = parseColor(color)
#print "Color:", name, color
else:
- raise ("need color and name, got %s %s" % (name, color))
+ raise SkinError("need color and name, got %s %s" % (name, color))
for c in skin.findall("fonts"):
for font in c.findall("font"):
try:
style.setColor(eWindowStyleSkinned.__dict__["col" + type], color)
except:
- raise ("Unknown color %s" % (type))
+ raise SkinError("Unknown color %s" % (type))
#pass
#print " color:", type, color