config.py: fix set/getValue for ConfigSelectionNumber
[enigma2.git] / lib / python / Components / Converter / FrontendInfo.py
index d4788b0b67c6ee99533b2fa1c28deeaf9ddaefe2..4043a1be53c820cbc0f5c0be1e0555c4b8de6668 100644 (file)
@@ -7,6 +7,8 @@ class FrontendInfo(Converter, object):
        AGC = 2
        LOCK = 3
        SNRdB = 4
        AGC = 2
        LOCK = 3
        SNRdB = 4
+       SLOT_NUMBER = 5
+       TUNER_TYPE = 6
 
        def __init__(self, type):
                Converter.__init__(self, type)
 
        def __init__(self, type):
                Converter.__init__(self, type)
@@ -18,12 +20,16 @@ class FrontendInfo(Converter, object):
                        self.type = self.SNRdB
                elif type == "AGC":
                        self.type = self.AGC
                        self.type = self.SNRdB
                elif type == "AGC":
                        self.type = self.AGC
+               elif type == "NUMBER":
+                       self.type = self.SLOT_NUMBER
+               elif type == "TYPE":
+                       self.type = self.TUNER_TYPE
                else:
                        self.type = self.LOCK
 
        @cached
        def getText(self):
                else:
                        self.type = self.LOCK
 
        @cached
        def getText(self):
-               assert self.type != self.LOCK, "the text output of FrontendInfo cannot be used for lock info"
+               assert self.type not in (self.LOCK, self.SLOT_NUMBER), "the text output of FrontendInfo cannot be used for lock info"
                percent = None
                if self.type == self.BER: # as count
                        count = self.source.ber
                percent = None
                if self.type == self.BER: # as count
                        count = self.source.ber
@@ -40,18 +46,25 @@ class FrontendInfo(Converter, object):
                                return "%3.02f dB" % (self.source.snr_db / 100.0)
                        elif self.source.snr is not None: #fallback to normal SNR...
                                percent = self.source.snr
                                return "%3.02f dB" % (self.source.snr_db / 100.0)
                        elif self.source.snr is not None: #fallback to normal SNR...
                                percent = self.source.snr
+               elif self.type == self.TUNER_TYPE:
+                       return self.source.frontend_type and self.frontend_type or "Unknown"
                if percent is None:
                        return "N/A"
                if percent is None:
                        return "N/A"
-
                return "%d %%" % (percent * 100 / 65536)
 
        @cached
        def getBool(self):
                return "%d %%" % (percent * 100 / 65536)
 
        @cached
        def getBool(self):
-               assert self.type in [self.LOCK, self.BER], "the boolean output of FrontendInfo can only be used for lock or BER info"
+               assert self.type in (self.LOCK, self.BER), "the boolean output of FrontendInfo can only be used for lock or BER info"
                if self.type == self.LOCK:
                if self.type == self.LOCK:
-                       return self.source.lock
+                       lock = self.source.lock
+                       if lock is None:
+                               lock = False
+                       return lock
                else:
                else:
-                       return self.source.ber > 0
+                       ber = self.source.ber
+                       if ber is None:
+                               ber = 0
+                       return ber > 0
 
        text = property(getText)
 
 
        text = property(getText)
 
@@ -69,6 +82,18 @@ class FrontendInfo(Converter, object):
                                return self.BER or 0
                        else:
                                return self.range
                                return self.BER or 0
                        else:
                                return self.range
+               elif self.type == self.TUNER_TYPE:
+                       type = self.source.frontend_type
+                       if type == 'DVB-S':
+                               return 0
+                       elif type == 'DVB-C':
+                               return 1
+                       elif type == 'DVB-T':
+                               return 2
+                       return -1
+               elif self.type == self.SLOT_NUMBER:
+                       num = self.source.slot_number
+                       return num is None and -1 or num
 
        range = 65536
        value = property(getValue)
 
        range = 65536
        value = property(getValue)