fixes for python 2.6 by Moritz Venn
authorghost <andreas.monzner@multimedia-labs.de>
Mon, 26 Jan 2009 23:04:59 +0000 (00:04 +0100)
committerghost <andreas.monzner@multimedia-labs.de>
Mon, 26 Jan 2009 23:04:59 +0000 (00:04 +0100)
17 files changed:
keymapparser.py
lib/actions/parseactions.py
lib/dvb/epgcache.cpp
lib/python/Components/Converter/EventTime.py
lib/python/Components/Converter/MovieInfo.py
lib/python/Components/Converter/ServicePosition.py
lib/python/Components/Converter/ServiceTime.py
lib/python/Components/Element.py
lib/python/Components/NimManager.py
lib/python/Components/Renderer/Canvas.py
lib/python/Plugins/DemoPlugins/TestPlugin/plugin.py
lib/python/Screens/ChannelSelection.py
lib/python/Screens/Setup.py
lib/python/Tools/LoadPixmap.py
lib/python/python.h
mytest.py
skin.py

index 5023e94..63bca0f 100644 (file)
@@ -1,11 +1,18 @@
 import enigma
 import xml.etree.cElementTree
 
 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
 
 
 # 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
 def parseKeys(context, filename, actionmap, device, keys):
        for x in keys.findall("key"):
                get_attr = x.attrib.get
@@ -29,12 +36,12 @@ def parseKeys(context, filename, actionmap, device, keys):
                        elif id[1] == 'd':
                                keyid = int(id[2:]) | 0x8000
                        else:
                        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:
                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)
 #                              print context + "::" + mapto + " -> " + device + "." + hex(keyid)
                actionmap.bindKey(filename, device, keyid, flags, context, mapto)
                addKeyBinding(filename, keyid, context, mapto, flags)
@@ -48,7 +55,7 @@ def readKeymap(filename):
        try:
                dom = xml.etree.cElementTree.parse(source)
        except:
        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()
 
 
        keymap = dom.getroot()
 
index 4ab71af..2462a75 100644 (file)
@@ -65,7 +65,7 @@ def do_file(f, mode):
                                        except:
                                                pass
                                
                                        except:
                                                pass
                                
-                                       raise "action enum must be simple."
+                                       raise Exception("action enum must be simple.")
                        
                                counter = 0
                        
                        
                                counter = 0
                        
@@ -82,7 +82,7 @@ def do_file(f, mode):
                                        
                                        if counter:
                                                if t != ",":
                                        
                                        if counter:
                                                if t != ",":
-                                                       raise "no comma"
+                                                       raise Exception("no comma")
                                                t = tokens.next()
                                
                                        if firsthit:
                                                t = tokens.next()
                                
                                        if firsthit:
index a8eca85..fdcbe0e 100644 (file)
@@ -2058,7 +2058,11 @@ PyObject *eEPGCache::search(ePyObject arg)
                        ePyObject obj = PyTuple_GET_ITEM(arg,0);
                        if (PyString_Check(obj))
                        {
                        ePyObject obj = PyTuple_GET_ITEM(arg,0);
                        if (PyString_Check(obj))
                        {
+#if PY_VERSION_HEX < 0x02060000
                                argcount = PyString_GET_SIZE(obj);
                                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])
                                argstring = PyString_AS_STRING(obj);
                                for (int i=0; i < argcount; ++i)
                                        switch(argstring[i])
@@ -2156,7 +2160,11 @@ PyObject *eEPGCache::search(ePyObject arg)
                                {
                                        int casetype = PyLong_AsLong(PyTuple_GET_ITEM(arg, 4));
                                        const char *str = PyString_AS_STRING(obj);
                                {
                                        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);
                                        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
                                        if (querytype == 1)
                                                eDebug("lookup for events with '%s' as title(%s)", str, casetype?"ignore case":"case sensitive");
                                        else
index 966f2ca..41f1ebf 100644 (file)
@@ -1,7 +1,7 @@
 from Converter import Converter
 from Poll import Poll
 from time import time
 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
 
 class EventTime(Poll, Converter, object):
        STARTTIME = 0
@@ -28,7 +28,7 @@ class EventTime(Poll, Converter, object):
                        self.poll_interval = 30*1000
                        self.poll_enabled = True
                else:
                        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):
 
        @cached
        def getTime(self):
index 068d24d..be28dcc 100644 (file)
@@ -1,5 +1,5 @@
 from Components.Converter.Converter import Converter
 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
 
 from enigma import iServiceInformation
 from ServiceReference import ServiceReference
 
@@ -16,7 +16,7 @@ class MovieInfo(Converter, object):
                elif type == "RecordServiceName":
                        self.type = self.MOVIE_REC_SERVICE_NAME
                else:
                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
                Converter.__init__(self, type)
 
        @cached
index d7a55da..2bcc549 100644 (file)
@@ -1,7 +1,7 @@
 from Converter import Converter
 from Poll import Poll
 from enigma import iPlayableService
 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
 
 class ServicePosition(Converter, Poll, object):
        TYPE_LENGTH = 0
@@ -35,7 +35,7 @@ class ServicePosition(Converter, Poll, object):
                elif type == "Gauge":
                        self.type = self.TYPE_GAUGE
                else:
                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
 
 
                self.poll_enabled = self.type != self.TYPE_LENGTH
 
index 16bcae3..8996506 100644 (file)
@@ -1,5 +1,5 @@
 from Converter import Converter
 from Converter import Converter
-from Components.Element import cached
+from Components.Element import cached, ElementError
 from enigma import iServiceInformation
 
 class ServiceTime(Converter, object):
 from enigma import iServiceInformation
 
 class ServiceTime(Converter, object):
@@ -16,7 +16,7 @@ class ServiceTime(Converter, object):
                elif type == "Duration":
                        self.type = self.DURATION
                else:
                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):
 
        @cached
        def getTime(self):
index 2af5779..f4a8f12 100644 (file)
@@ -16,6 +16,13 @@ def cached(f):
                return cache[name][1]
        return wrapper
 
                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
 class Element(object):
        CHANGED_DEFAULT = 0   # initial "pull" state
        CHANGED_ALL = 1       # really everything changed
index 1fcbda1..2692cb5 100644 (file)
@@ -14,8 +14,6 @@ from enigma import eDVBSatelliteEquipmentControl as secClass, \
 from time import localtime, mktime
 from datetime import datetime
 
 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 getConfigSatlist(orbpos, satlist):
        default_orbpos = None
        for x in satlist:
@@ -123,7 +121,7 @@ class SecConfigure:
 
        def update(self):
                sec = secClass.getInstance()
 
        def update(self):
                sec = secClass.getInstance()
-               self.configuredSatellites = Set()
+               self.configuredSatellites = set()
                sec.clear() ## this do unlinking NIMs too !!
                print "sec config cleared"
 
                sec.clear() ## this do unlinking NIMs too !!
                print "sec config cleared"
 
@@ -442,7 +440,7 @@ class SecConfigure:
 
        def __init__(self, nimmgr):
                self.NimManager = nimmgr
 
        def __init__(self, nimmgr):
                self.NimManager = nimmgr
-               self.configuredSatellites = Set()
+               self.configuredSatellites = set()
                self.update()
 
 class NIM(object):
                self.update()
 
 class NIM(object):
index bd7ffb5..acf0dbf 100644 (file)
@@ -35,7 +35,7 @@ class Canvas(Renderer):
                                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
                                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 changed(self, what):
                self.pull_updates()
index a63562c..69f935e 100644 (file)
@@ -51,7 +51,7 @@ class Test(Screen):
        def mycallback(self, answer):
                print "answer:", answer
                if answer:
        def mycallback(self, answer):
                print "answer:", answer
                if answer:
-                       raise "test-crash"
+                       raise Exception("test-crash")
                self.close()
        
        def keyLeft(self):
                self.close()
        
        def keyLeft(self):
index b203b24..ebfbe81 100644 (file)
@@ -76,7 +76,7 @@ def append_when_current_valid(current, menu, args, level = 0):
 class ChannelContextMenu(Screen):
        def __init__(self, session, csel):
                Screen.__init__(self, session)
 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
 
                self.csel = csel
                self.bsel = None
 
index 35918b5..1d035b8 100644 (file)
@@ -19,6 +19,13 @@ except:
 setupdom = xml.etree.cElementTree.parse(setupfile)
 setupfile.close()
 
 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">
 class SetupSummary(Screen):
        skin = """
        <screen position="6,0" size="120,64">
@@ -145,4 +152,4 @@ def getSetupTitle(id):
        for x in xmldata.findall("setup"):
                if x.get("key") == id:
                        return x.get("title", "").encode("UTF-8")
        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))
index 53e04e5..fff414a 100644 (file)
@@ -14,7 +14,7 @@ def LoadPixmap(path, desktop = None, cached = False):
                alpha = loadPNG(path + "a.png")
                ptr = loadJPG(path + "rgb.jpg", alpha)
        else:
                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)
 
        if ptr and desktop:
                desktop.makeCompatiblePixmap(ptr)
 
index f56d49b..52ec6c1 100644 (file)
@@ -24,6 +24,7 @@ public:
 #ifdef PYTHON_REFCOUNT_DEBUG
        inline ePyObject(PyObject *ob, const char *file, int line);
 #endif
 #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);
        inline ePyObject(PyDictObject *ob);
        inline ePyObject(PyTupleObject *ob);
        inline ePyObject(PyListObject *ob);
@@ -32,11 +33,13 @@ public:
        operator bool() { return !!m_ob; }
        ePyObject &operator=(const ePyObject &);
        ePyObject &operator=(PyObject *);
        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*();
        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*(); }
        operator PyTupleObject*() { return (PyTupleObject*)operator PyObject*(); }
        operator PyListObject*() { return (PyListObject*)operator PyObject*(); }
        operator PyStringObject*() { return (PyStringObject*)operator PyObject*(); }
@@ -84,6 +87,14 @@ inline ePyObject::ePyObject(PyObject *ob, const char* file, int line)
 }
 #endif
 
 }
 #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
 inline ePyObject::ePyObject(PyDictObject *ob)
        :m_ob((PyObject*)ob)
 #ifdef PYTHON_REFCOUNT_DEBUG
index 014f94c..8f23bea 100644 (file)
--- a/mytest.py
+++ b/mytest.py
@@ -277,7 +277,7 @@ class Session:
 
        def open(self, screen, *arguments, **kwargs):
                if len(self.dialog_stack) and not self.in_exec:
 
        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()
                        # ...unless it's the very first screen.
 
                self.pushCurrent()
diff --git a/skin.py b/skin.py
index eae6ea4..03fe96b 100644 (file)
--- a/skin.py
+++ b/skin.py
@@ -274,7 +274,7 @@ def loadSingleSkinData(desktop, skin, path_prefix):
                                colorNames[name] = parseColor(color)
                                #print "Color:", name, color
                        else:
                                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"):
 
        for c in skin.findall("fonts"):
                for font in c.findall("font"):
@@ -335,7 +335,7 @@ def loadSingleSkinData(desktop, skin, path_prefix):
                        try:
                                style.setColor(eWindowStyleSkinned.__dict__["col" + type], color)
                        except:
                        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
                                #pass
 
                        #print "  color:", type, color