Introduce getGStreamerVersionString function and use it in About screen
[openblackhole/openblackhole-enigma2.git] / lib / python / Screens / About.py
1 from Screen import Screen
2 from Components.ActionMap import ActionMap
3 from Components.Sources.StaticText import StaticText
4 from Components.Harddisk import harddiskmanager
5 from Components.NimManager import nimmanager
6 from Components.About import about
7 from Components.ScrollLabel import ScrollLabel
8 from Components.Button import Button
9
10 from Tools.StbHardware import getFPVersion
11 from enigma import eTimer
12
13 class About(Screen):
14         def __init__(self, session):
15                 Screen.__init__(self, session)
16
17
18                 AboutText = _("Hardware: ") + about.getHardwareTypeString() + "\n"
19                 AboutText += _("CPU: ") + about.getCPUInfoString() + "\n"
20                 AboutText += _("Image: ") + about.getImageTypeString() + "\n"
21                 AboutText += _("Kernel version: ") + about.getKernelVersionString() + "\n"
22
23                 EnigmaVersion = "Enigma: " + about.getEnigmaVersionString()
24                 self["EnigmaVersion"] = StaticText(EnigmaVersion)
25                 AboutText += EnigmaVersion + "\n"
26
27                 GStreamerVersion = "GStreamer: " + about.getGStreamerVersionString()
28                 self["GStreamerVersion"] = StaticText(GStreamerVersion)
29                 AboutText += GStreamerVersion + "\n"
30
31                 ImageVersion = _("Last upgrade: ") + about.getImageVersionString()
32                 self["ImageVersion"] = StaticText(ImageVersion)
33                 AboutText += ImageVersion + "\n"
34
35                 fp_version = getFPVersion()
36                 if fp_version is None:
37                         fp_version = ""
38                 else:
39                         fp_version = _("Frontprocessor version: %d") % fp_version
40                         AboutText += fp_version + "\n"
41
42                 self["FPVersion"] = StaticText(fp_version)
43
44                 self["TunerHeader"] = StaticText(_("Detected NIMs:"))
45                 AboutText += "\n" + _("Detected NIMs:") + "\n"
46
47                 nims = nimmanager.nimList()
48                 for count in range(len(nims)):
49                         if count < 4:
50                                 self["Tuner" + str(count)] = StaticText(nims[count])
51                         else:
52                                 self["Tuner" + str(count)] = StaticText("")
53                         AboutText += nims[count] + "\n"
54
55                 self["HDDHeader"] = StaticText(_("Detected HDD:"))
56                 AboutText += "\n" + _("Detected HDD:") + "\n"
57
58                 hddlist = harddiskmanager.HDDList()
59                 hddinfo = ""
60                 if hddlist:
61                         for count in range(len(hddlist)):
62                                 if hddinfo:
63                                         hddinfo += "\n"
64                                 hdd = hddlist[count][1]
65                                 if int(hdd.free()) > 1024:
66                                         hddinfo += "%s\n(%s, %d GB %s)" % (hdd.model(), hdd.capacity(), hdd.free()/1024, _("free"))
67                                 else:
68                                         hddinfo += "%s\n(%s, %d MB %s)" % (hdd.model(), hdd.capacity(), hdd.free(), _("free"))
69                 else:
70                         hddinfo = _("none")
71                 self["hddA"] = StaticText(hddinfo)
72                 AboutText += hddinfo
73                 self["AboutScrollLabel"] = ScrollLabel(AboutText)
74                 self["key_green"] = Button(_("Translations"))
75                 self["key_red"] = Button(_("Latest Commits"))
76
77                 self["actions"] = ActionMap(["ColorActions", "SetupActions", "DirectionActions"],
78                         {
79                                 "cancel": self.close,
80                                 "ok": self.close,
81                                 "red": self.showCommits,
82                                 "green": self.showTranslationInfo,
83                                 "up": self["AboutScrollLabel"].pageUp,
84                                 "down": self["AboutScrollLabel"].pageDown
85                         })
86
87         def showTranslationInfo(self):
88                 self.session.open(TranslationInfo)
89
90         def showCommits(self):
91                 self.session.open(CommitInfo)
92
93 class TranslationInfo(Screen):
94         def __init__(self, session):
95                 Screen.__init__(self, session)
96                 # don't remove the string out of the _(), or it can't be "translated" anymore.
97
98                 # TRANSLATORS: Add here whatever should be shown in the "translator" about screen, up to 6 lines (use \n for newline)
99                 info = _("TRANSLATOR_INFO")
100
101                 if info == "TRANSLATOR_INFO":
102                         info = "(N/A)"
103
104                 infolines = _("").split("\n")
105                 infomap = {}
106                 for x in infolines:
107                         l = x.split(': ')
108                         if len(l) != 2:
109                                 continue
110                         (type, value) = l
111                         infomap[type] = value
112                 print infomap
113
114                 self["TranslationInfo"] = StaticText(info)
115
116                 translator_name = infomap.get("Language-Team", "none")
117                 if translator_name == "none":
118                         translator_name = infomap.get("Last-Translator", "")
119
120                 self["TranslatorName"] = StaticText(translator_name)
121
122                 self["actions"] = ActionMap(["SetupActions"],
123                         {
124                                 "cancel": self.close,
125                                 "ok": self.close,
126                         })
127
128 class CommitInfo(Screen):
129         def __init__(self, session):
130                 Screen.__init__(self, session)
131                 self.skinName = ["CommitInfo", "About"]
132                 self["AboutScrollLabel"] = ScrollLabel(_("Please wait"))
133
134                 self["actions"] = ActionMap(["SetupActions", "DirectionActions"],
135                         {
136                                 "cancel": self.close,
137                                 "ok": self.close,
138                                 "up": self["AboutScrollLabel"].pageUp,
139                                 "down": self["AboutScrollLabel"].pageDown,
140                                 "left": self.left,
141                                 "right": self.right
142                         })
143
144                 self.project = 0
145                 self.projects = [
146                         ("enigma2", "Enigma2"),
147                         ("openpli-oe-core", "Openpli Oe Core"),
148                         ("enigma2-plugins", "Enigma2 Plugins"),
149                         ("aio-grab", "Aio Grab"),
150                         ("gst-plugin-dvbmediasink", "Gst Plugin Dvbmediasink"),
151                         ("openembedded", "Openembedded"),
152                         ("plugin-xmltvimport", "Plugin Xmltvimport"),
153                         ("plugins-enigma2", "Plugins Enigma2"),
154                         ("skin-magic", "Skin Magic"),
155                         ("tuxtxt", "Tuxtxt")
156                 ]
157                 self.cachedProjects = {}
158                 self.Timer = eTimer()
159                 self.Timer.callback.append(self.readCommitLogs)
160                 self.Timer.start(50, True)
161
162         def readCommitLogs(self):
163                 url = 'http://sourceforge.net/p/openpli/%s/feed' % self.projects[self.project][0]
164                 commitlog = ""
165                 from urllib2 import urlopen
166                 try:
167                         commitlog += 80 * '-' + '\n'
168                         commitlog += url.split('/')[-2] + '\n'
169                         commitlog += 80 * '-' + '\n'
170                         for x in  urlopen(url, timeout=5).read().split('<title>')[2:]:
171                                 for y in x.split("><"):
172                                         if '</title' in y:
173                                                 title = y[:-7]
174                                         if '</dc:creator' in y:
175                                                 creator = y.split('>')[1].split('<')[0]
176                                         if '</pubDate' in y:
177                                                 date = y.split('>')[1].split('<')[0][:-6]
178                                 commitlog += date + ' ' + creator + '\n' + title + 2 * '\n'
179                         self.cachedProjects[self.projects[self.project][1]] = commitlog
180                 except:
181                         commitlog = _("Currently the commit log cannot be retrieved - please try later again")
182                 self["AboutScrollLabel"].setText(commitlog)
183
184         def updateCommitLogs(self):
185                 if self.cachedProjects.has_key(self.projects[self.project][1]):
186                         self["AboutScrollLabel"].setText(self.cachedProjects[self.projects[self.project][1]])
187                 else:
188                         self["AboutScrollLabel"].setText(_("Please wait"))
189                         self.Timer.start(50, True)
190
191         def left(self):
192                 self.project = self.project == 0 and len(self.projects) - 1 or self.project - 1
193                 self.updateCommitLogs()
194
195         def right(self):
196                 self.project = self.project != len(self.projects) - 1 and self.project + 1 or 0
197                 self.updateCommitLogs()