fix crash on display settings
[dreambox-avalon_II.git] / usr / lib / enigma2 / python / Components / Renderer / SmartLabel.py
1 from Components.VariableText import VariableText\r
2 from enigma import eLabel, iServiceInformation\r
3 from Renderer import Renderer\r
4 \r
5 \r
6 \r
7 class SmartLabel(Renderer, VariableText):\r
8         def __init__(self):\r
9                 Renderer.__init__(self)\r
10                 VariableText.__init__(self)\r
11 \r
12         GUI_WIDGET = eLabel\r
13 \r
14         def changed(self, what):\r
15                 service = self.source.service\r
16                 info = service and service.info()\r
17                 if info is not None:\r
18                         if (info.getInfo(iServiceInformation.sIsCrypted) == 1):\r
19                                 decID = ""\r
20                                 decFrom = ""\r
21                                 xresol = 0\r
22                                 yresol = 0\r
23                                 try:\r
24                                         f = open("/tmp/ecm.info", "r")\r
25                                         flines = f.readlines()\r
26                                         f.close()\r
27                                         for cell in flines:\r
28                                                 if ("caid" in cell)or("CAID" in cell)or("CaID" in cell)or("caID" in cell)or("Caid" in cell):\r
29                                                         cellmembers = cell.split()\r
30                                                         for x in range(len(cellmembers)):\r
31                                                                 if ("caid" in cellmembers[x])or("CAID" in cellmembers[x])or("CaID" in cellmembers[x])or("caID" in cellmembers[x])or("Caid" in cellmembers[x]):\r
32                                                                         if x<(len(cellmembers)-1):\r
33                                                                                 if cellmembers[x+1] != "0x000":\r
34                                                                                         decID = cellmembers[x+1]\r
35                                                                                         decID = decID .lstrip("0x")\r
36                                                                                         decID = decID.strip(",;.:-*_<>()[]{}")\r
37                                                                                         if (len(decID)<4):\r
38                                                                                                 decID = decID + "0"\r
39                                                                                 else:\r
40                                                                                         decID = ""\r
41                                         if decID != "":\r
42                                                 idnames = ("0100,01FF,SE","0500,05FF,VI","0600,06FF,IR","0900,09FF,NDS","0B00,0BFF,CO","0D00,0DFF,CW","1700,17FF,BC","1800,18FF,NA")\r
43                                                 for idline in idnames:\r
44                                                         IDlist = idline.split(",")\r
45                                                         try:\r
46                                                                 if (int(decID,16)>=int(IDlist[0],16)) and (int(decID,16)<=int(IDlist[1],16)):\r
47                                                                         decID = IDlist[2] + " " + decID\r
48                                                                         break\r
49                                                         except:\r
50                                                                 pass\r
51                                         for cell in flines:\r
52                                                 if ("using:" in cell) or ("source:" in cell):\r
53                                                         cellmembers = cell.split()\r
54                                                         for x in range(len(cellmembers)):\r
55                                                                 if ("using:" in cellmembers[x]) or ("source:" in cellmembers[x]):\r
56                                                                         if x<(len(cellmembers)-1):\r
57                                                                                 if cellmembers[x+1] != "fta":\r
58                                                                                         decFrom = cellmembers[x+1]\r
59                                                                                 else:\r
60                                                                                         decFrom = ""\r
61                                 except:\r
62                                         pass\r
63                                 self.text = decFrom + " " + decID\r
64                         else:\r
65                                 xresol = info.getInfo(iServiceInformation.sVideoWidth)\r
66                                 yresol = info.getInfo(iServiceInformation.sVideoHeight)\r
67                                 if xresol>0:\r
68                                         self.text = str(xresol) + " x " + str(yresol)\r
69 \r
70 \r
71 \r