1 # twisted-mail twisted-names python-compression python-mime python-email
4 from Plugins.Plugin import PluginDescriptor
6 from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigText, ConfigSelection, ConfigYesNo,ConfigText
7 from Components.ConfigList import ConfigListScreen
8 from Components.ActionMap import ActionMap
9 from Components.Sources.StaticText import StaticText
10 from Components.Pixmap import Pixmap
11 from Components.Label import Label
13 from Screens.Screen import Screen
14 from Screens.VirtualKeyBoard import VirtualKeyBoard
15 from Screens.ChoiceBox import ChoiceBox
16 from Screens.MessageBox import MessageBox
18 from enigma import ePoint, eConsoleAppContainer, getDesktop
20 from Tools.Directories import resolveFilename, SCOPE_PLUGINS
22 g_configfile=resolveFilename(SCOPE_PLUGINS, "SystemPlugins/CrashReport/settings")
23 g_senderfile=resolveFilename(SCOPE_PLUGINS, "SystemPlugins/CrashReport/sender.py")
25 g_default_activation = ""
26 g_default_aftersummit = ""
27 g_default_optionalinfo = False
28 g_default_username = ""
29 g_default_useremail = ""
30 g_default_machineinfo = True
34 #print "---->>[%s][%d][%d]" % (str, len(str), idx)
41 def saveConfig(activation, aftersummit, machineinfo, optionalinfo, username="", useremail=""):
44 configs.append("activation=%s\n" % (activation))
45 configs.append("aftersummit=%s\n" % (aftersummit))
46 configs.append("optionalinfo=%s\n" % (str(optionalinfo)))
47 configs.append("username=%s\n" % (username))
48 configs.append("useremail=%s\n" % (useremail))
49 configs.append("machineinfo=%s\n" % (str(machineinfo)))
51 f = open(g_configfile, 'w')
58 if os.path.exists(g_configfile) == False:
60 global g_default_activation
61 global g_default_aftersummit
62 global g_default_optionalinfo
63 global g_default_username
64 global g_default_useremail
65 global g_default_machineinfo
66 f = open(g_configfile)
67 conf_list = f.readlines()
69 print "load config : ", conf_list
70 if len(conf_list) < 6:
72 g_default_activation = getValue(conf_list[0].strip())
73 g_default_aftersummit = getValue(conf_list[1].strip())
74 if getValue(conf_list[2].strip()) == "True":
75 g_default_optionalinfo = True
76 g_default_username = getValue(conf_list[3].strip())
77 g_default_useremail = getValue(conf_list[4].strip())
78 if getValue(conf_list[5].strip()) == "False":
79 g_default_machineinfo = False
81 class CrashlogReportConfiguration(Screen, ConfigListScreen):
84 <screen name="CrashlogReportSetting" position="209,48" size="865,623" title="CrashlogReport Setting" flags="wfNoBorder" backgroundColor="transparent">
85 <ePixmap pixmap="Vu_HD/Bg_EPG_list.png" zPosition="-1" position="0,0" size="865,623" alphatest="on" />
86 <ePixmap pixmap="Vu_HD/menu/ico_title_Setup.png" position="32,41" size="40,40" alphatest="blend" transparent="1" />
87 <eLabel text="CrashlogReport Setting" position="90,50" size="600,32" font="Semiboldit;32" foregroundColor="#5d5d5d" backgroundColor="#27b5b9bd" transparent="1" />
88 <ePixmap pixmap="Vu_HD/icons/clock.png" position="750,55" zPosition="1" size="20,20" alphatest="blend" />
89 <widget source="global.CurrentTime" render="Label" position="770,57" zPosition="1" size="50,20" font="Regular;20" foregroundColor="#1c1c1c" halign="right" backgroundColor="#27d9dee2" transparent="1">
90 <convert type="ClockToText">Format:%H:%M</convert>
92 <ePixmap pixmap="Vu_HD/buttons/red.png" position="45,98" size="25,25" alphatest="blend" />
93 <ePixmap pixmap="Vu_HD/buttons/green.png" position="240,98" size="25,25" alphatest="blend" />
94 <ePixmap pixmap="Vu_HD/buttons/button_off.png" position="435,98" size="25,25" alphatest="blend" />
95 <ePixmap pixmap="Vu_HD/buttons/button_off.png" position="630,98" size="25,25" alphatest="blend" />
96 <widget source="key_red" render="Label" position="66,97" zPosition="1" size="150,25" font="Regular;20" halign="center" valign="center" backgroundColor="darkgrey" foregroundColor="#1c1c1c" transparent="1" />
97 <widget source="key_green" render="Label" position="268,97" zPosition="1" size="150,25" font="Regular;20" halign="center" valign="center" backgroundColor="darkgrey" foregroundColor="#1c1c1c" transparent="1" />
98 <widget name="config" zPosition="2" position="50,130" itemHeight="36" size="750,324" scrollbarMode="showOnDemand" transparent="1" />
99 <widget source="status" render="Label" position="160,525" size="540,60" zPosition="10" foregroundColor="#3c3c3c" backgroundColor="#27aeaeae" font="Regular;20" halign="center" valign="center" transparent="1"/>
100 <widget name="VKeyIcon" pixmap="Vu_HD/buttons/key_text.png" position="500,350" zPosition="10" size="35,25" transparent="1" alphatest="on" />
101 <widget name="HelpWindow" pixmap="Vu_HD/vkey_icon.png" position="310,400" zPosition="1" size="1,1" transparent="1" alphatest="on" />
104 skin_list["sd"] = """
105 <screen name="CrashlogReportSetting" position="center,120" size="560,420" title="CrashlogReport Settings" >
106 <ePixmap pixmap="750S/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
107 <ePixmap pixmap="750S/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
108 <widget source="key_red" render="Label" position="20,0" zPosition="1" size="115,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
109 <widget source="key_green" render="Label" position="160,0" zPosition="1" size="115,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
110 <widget name="config" zPosition="2" position="5,50" size="550,300" scrollbarMode="showOnDemand" transparent="1" />
111 <ePixmap pixmap="750S/div-h.png" position="0,360" zPosition="10" size="560,2" transparent="1" alphatest="on" />
112 <widget source="status" render="Label" position="10,370" size="540,40" zPosition="10" font="Regular;20" halign="center" valign="center" backgroundColor="#25062748" transparent="1"/>
113 <widget name="VKeyIcon" pixmap="750S/buttons/key_text.png" position="10,390" zPosition="10" size="35,25" transparent="1" alphatest="on" />
114 <widget name="HelpWindow" pixmap="750S/vkey_icon.png" position="160,300" zPosition="1" size="1,1" transparent="1" alphatest="on" />
118 size = getDesktop(0).size()
119 skin = skin_list[size.width() > 750 and "hd" or "sd"]
121 def __init__(self, session):
122 Screen.__init__(self, session)
123 self.session = session
125 self["shortcuts"] = ActionMap(["ShortcutActions", "SetupActions" ],
128 "cancel": self.keyCancel,
129 "red": self.keyCancel,
132 self["VirtualKB"] = ActionMap(["VirtualKeyboardActions" ],
134 "showVirtualKeyboard": self.cbSetTitle,
138 ConfigListScreen.__init__(self, self.list, session=self.session)
139 self["key_red"] = StaticText(_("Close"))
140 self["key_green"] = StaticText(_("Save"))
141 self["status"] = StaticText(" ")
142 self["VKeyIcon"] = Pixmap()
143 self["HelpWindow"] = Pixmap()
145 self["VKeyIcon"].hide()
146 self["VirtualKB"].setEnabled(False)
151 def initGlobal(self):
152 global g_default_activation
153 global g_default_aftersummit
154 global g_default_optionalinfo
155 global g_default_username
156 global g_default_useremail
157 global g_default_machineinfo
158 if g_default_activation == "":
159 g_default_activation = "send_summit"
160 if g_default_aftersummit == "":
161 g_default_aftersummit = "rename"
162 g_default_optionalinfo
163 if g_default_username == "":
164 g_default_username = "Vuplus User"
165 if g_default_useremail == "":
166 g_default_useremail = "yourmail@here.is"
167 self.g_activation = ConfigSelection(default=g_default_activation, choices=[("send_summit", _("Enable")), ("send_disable", _("Disable"))])
168 self.g_aftersummit = ConfigSelection(default=g_default_aftersummit, choices=[("rename", _("Rename")), ("delete", _("Delete"))])
169 self.g_optionalinfo = ConfigYesNo(default = g_default_optionalinfo)
170 self.g_username = ConfigText(default = g_default_username, fixed_size = False)
171 self.g_useremail = ConfigText(default = g_default_useremail, fixed_size = False)
172 self.g_machineinfo = ConfigYesNo(default = g_default_machineinfo)
174 self._activation = getConfigListEntry(_("Activation mode"), self.g_activation)
175 self._after_action = getConfigListEntry(_("Action after summit"), self.g_aftersummit)
176 self._add_user_info = getConfigListEntry(_("Include optional infomation"), self.g_optionalinfo)
177 self._user_info_name = getConfigListEntry(_("User name"), self.g_username)
178 self._user_info_mail = getConfigListEntry(_("User Email"), self.g_useremail)
179 self._machineinfo = getConfigListEntry(_("Include settop information"), self.g_machineinfo)
181 if not self.cbSelectionChanged in self["config"].onSelectionChanged:
182 self["config"].onSelectionChanged.append(self.cbSelectionChanged)
186 self.list.append(self._activation)
187 if self.g_activation.value == "send_summit":
188 self.list.append(self._after_action)
189 self.list.append(self._add_user_info)
190 if self.g_optionalinfo.value:
191 self.list.append(self._user_info_name)
192 self.list.append(self._user_info_mail)
193 self.list.append(self._machineinfo)
194 self["config"].list = self.list
195 self["config"].l.setList(self.list)
198 if self["config"].getCurrent() == self._activation or self["config"].getCurrent() == self._add_user_info:
201 def cbSelectionChanged(self):
202 current = self["config"].getCurrent()
203 if current == self._activation:
204 self.enableVKIcon(False)
205 elif current == self._after_action:
206 self.enableVKIcon(False)
207 elif current == self._add_user_info:
208 self.enableVKIcon(False)
209 elif current == self._user_info_name:
210 self.enableVKIcon(True)
211 elif current == self._user_info_mail:
212 self.enableVKIcon(True)
213 elif current == self._machineinfo:
214 self.enableVKIcon(False)
216 def cbSetTitle(self):
218 if self["config"].getCurrent() == self._user_info_mail:
219 t = "Please enter user email:"
220 if self["config"].getCurrent() == self._user_info_name:
221 t = "Please enter user name:"
222 self.session.openWithCallback(self.NameCallback, VirtualKeyBoard, title = (t), text = self._user_info_name.value)
224 def enableVKIcon(self, mode):
226 self["VKeyIcon"].show()
228 self["VKeyIcon"].hide()
229 self["VirtualKB"].setEnabled(True)
231 def saveConfig(self):
232 if self.g_optionalinfo.value:
233 saveConfig(self.g_activation.value, self.g_aftersummit.value, self.g_machineinfo.value, self.g_optionalinfo.value, self.g_username.value, self.g_useremail.value)
235 saveConfig(self.g_activation.value, self.g_aftersummit.value, self.g_machineinfo.value, self.g_optionalinfo.value)
238 ConfigListScreen.keyLeft(self)
242 ConfigListScreen.keyRight(self)
251 if os.path.exists(g_configfile) == False:
255 def main(session, **kwargs):
257 session.open(CrashlogReportConfiguration)
259 def opensetting(menuid, **kwargs):
260 if menuid != "system":
262 return [(_("Crashlog Reporting"), main, "crashlog_configure", 70)]
264 def generateInformation():
266 from Tools.DreamboxHardware import getFPVersion
267 from Components.Harddisk import harddiskmanager
268 from Components.NimManager import nimmanager
269 from Components.About import about
272 result = popen(cmd, "r").read().strip()
277 "kernel : %s\n"%(command("uname -a"))
278 ,"version : %s (%s)\n"%(str(about.getImageVersionString()), str(about.getEnigmaVersionString()))
279 ,"frontprocessor : %s\n"%(str(getFPVersion()))
280 ,"frontend : %s\n"%(str(nimmanager.nimList()))
281 ,"hdd info : %s\n"%(str(harddiskmanager.HDDList()))
282 ,"network information : \n%s\n"%(command("ifconfig -a"))
284 f = open("/tmp/machine.info", 'w')
285 f.writelines(information)
289 def autosubmit(reason, **kwargs):
290 global g_default_activation
291 global g_default_aftersummit
292 global g_default_username
293 global g_default_useremail
295 print "[CrashReport] auto submit"
298 def isExistCrashlog(d='/media/hdd'):
300 for f in os.listdir(d):
301 if f.startswith("enigma2_crash_") and f.endswith(".log"):
307 def cbDataAvail(ret_data):
309 def cbAppClosed(retval):
310 if os.path.exists("/tmp/machine.info"):
311 os.system("rm -f /tmp/machine.info")
313 if "session" in kwargs:
314 if isExistCrashlog() == False:
315 print "[CrashReport] no crash-log"
317 session = kwargs["session"]
318 if g_default_activation == "send_summit":
321 sender = eConsoleAppContainer()
322 sender.dataAvail.append(cbDataAvail)
323 sender.appClosed.append(cbAppClosed)
325 if g_default_username == "":
328 un = g_default_username
329 if g_default_useremail == "":
330 um = "yourmail@here.is"
332 um = g_default_useremail
333 if g_default_machineinfo:
334 generateInformation()
336 sender.execute(_("python %s %s %s %s" % (g_senderfile, um, un.replace(" ", "_"), g_default_aftersummit)))
338 def Plugins(**kwargs):
339 return [PluginDescriptor(where = [PluginDescriptor.WHERE_SESSIONSTART], needsRestart = False, fnc = autosubmit),
340 PluginDescriptor(name=_("CrashlogReportSetting"), description=_("CrashlogReport setting"),where=PluginDescriptor.WHERE_MENU, needsRestart = False, fnc=opensetting)]