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):
83 <screen position="center,120" size="560,420" title="CrashlogReport Settings" >
84 <ePixmap pixmap="skin_default/buttons/red.png" position="110,10" size="140,40" alphatest="on" />
85 <ePixmap pixmap="skin_default/buttons/green.png" position="310,10" size="140,40" alphatest="on" />
87 <widget source="key_red" render="Label" position="110,10" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" foregroundColor="#ffffff" transparent="1" />
88 <widget source="key_green" render="Label" position="310,10" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" foregroundColor="#ffffff" transparent="1" />
90 <widget name="config" zPosition="2" position="5,70" size="550,300" scrollbarMode="showOnDemand" transparent="1" />
91 <ePixmap pixmap="skin_default/div-h.png" position="0,360" zPosition="10" size="560,2" transparent="1" alphatest="on" />
92 <widget source="status" render="Label" position="10,370" size="540,40" zPosition="10" font="Regular;20" halign="center" valign="center" backgroundColor="#25062748" transparent="1"/>
93 <widget name="VKeyIcon" pixmap="skin_default/buttons/key_text.png" position="10,390" zPosition="10" size="35,25" transparent="1" alphatest="on" />
94 <widget name="HelpWindow" pixmap="skin_default/vkey_icon.png" position="160,350" zPosition="1" size="1,1" transparent="1" alphatest="on" />
98 def __init__(self, session):
99 Screen.__init__(self, session)
100 self.session = session
102 self["shortcuts"] = ActionMap(["ShortcutActions", "SetupActions" ],
105 "cancel": self.keyCancel,
106 "red": self.keyCancel,
109 self["VirtualKB"] = ActionMap(["VirtualKeyboardActions" ],
111 "showVirtualKeyboard": self.cbSetTitle,
115 ConfigListScreen.__init__(self, self.list, session=self.session)
116 self["key_red"] = StaticText(_("Close"))
117 self["key_green"] = StaticText(_("Save"))
118 self["status"] = StaticText(" ")
119 self["VKeyIcon"] = Pixmap()
120 self["HelpWindow"] = Pixmap()
122 self["VKeyIcon"].hide()
123 self["VirtualKB"].setEnabled(False)
128 def initGlobal(self):
129 global g_default_activation
130 global g_default_aftersummit
131 global g_default_optionalinfo
132 global g_default_username
133 global g_default_useremail
134 global g_default_machineinfo
135 if g_default_activation == "":
136 g_default_activation = "send_summit"
137 if g_default_aftersummit == "":
138 g_default_aftersummit = "rename"
139 g_default_optionalinfo
140 if g_default_username == "":
141 g_default_username = "Vuplus User"
142 if g_default_useremail == "":
143 g_default_useremail = "yourmail@here.is"
144 self.g_activation = ConfigSelection(default=g_default_activation, choices=[("send_summit", _("Enable")), ("send_disable", _("Disable"))])
145 self.g_aftersummit = ConfigSelection(default=g_default_aftersummit, choices=[("rename", _("Rename")), ("delete", _("Delete"))])
146 self.g_optionalinfo = ConfigYesNo(default = g_default_optionalinfo)
147 self.g_username = ConfigText(default = g_default_username, fixed_size = False)
148 self.g_useremail = ConfigText(default = g_default_useremail, fixed_size = False)
149 self.g_machineinfo = ConfigYesNo(default = g_default_machineinfo)
151 self._activation = getConfigListEntry(_("Activation mode"), self.g_activation)
152 self._after_action = getConfigListEntry(_("Action after summit"), self.g_aftersummit)
153 self._add_user_info = getConfigListEntry(_("Include optional infomation"), self.g_optionalinfo)
154 self._user_info_name = getConfigListEntry(_("User name"), self.g_username)
155 self._user_info_mail = getConfigListEntry(_("User Email"), self.g_useremail)
156 self._machineinfo = getConfigListEntry(_("Include settop information"), self.g_machineinfo)
158 if not self.cbSelectionChanged in self["config"].onSelectionChanged:
159 self["config"].onSelectionChanged.append(self.cbSelectionChanged)
163 self.list.append(self._activation)
164 if self.g_activation.value == "send_summit":
165 self.list.append(self._after_action)
166 self.list.append(self._add_user_info)
167 if self.g_optionalinfo.value:
168 self.list.append(self._user_info_name)
169 self.list.append(self._user_info_mail)
170 self.list.append(self._machineinfo)
171 self["config"].list = self.list
172 self["config"].l.setList(self.list)
175 if self["config"].getCurrent() == self._activation or self["config"].getCurrent() == self._add_user_info:
178 def cbSelectionChanged(self):
179 current = self["config"].getCurrent()
180 if current == self._activation:
181 self.enableVKIcon(False)
182 elif current == self._after_action:
183 self.enableVKIcon(False)
184 elif current == self._add_user_info:
185 self.enableVKIcon(False)
186 elif current == self._user_info_name:
187 self.enableVKIcon(True)
188 elif current == self._user_info_mail:
189 self.enableVKIcon(True)
190 elif current == self._machineinfo:
191 self.enableVKIcon(False)
193 def cbSetTitle(self):
195 if self["config"].getCurrent() == self._user_info_mail:
196 t = "Please enter user email:"
197 if self["config"].getCurrent() == self._user_info_name:
198 t = "Please enter user name:"
199 self.session.openWithCallback(self.NameCallback, VirtualKeyBoard, title = (t), text = self._user_info_name.value)
201 def enableVKIcon(self, mode):
203 self["VKeyIcon"].show()
205 self["VKeyIcon"].hide()
206 self["VirtualKB"].setEnabled(True)
208 def saveConfig(self):
209 if self.g_optionalinfo.value:
210 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)
212 saveConfig(self.g_activation.value, self.g_aftersummit.value, self.g_machineinfo.value, self.g_optionalinfo.value)
215 ConfigListScreen.keyLeft(self)
219 ConfigListScreen.keyRight(self)
228 if os.path.exists(g_configfile) == False:
232 def main(session, **kwargs):
234 session.open(CrashlogReportConfiguration)
236 def opensetting(menuid, **kwargs):
237 if menuid != "system":
239 return [(_("Crashlog Reporting"), main, "crashlog_configure", 70)]
241 def generateInformation():
243 from Tools.DreamboxHardware import getFPVersion
244 from Components.Harddisk import harddiskmanager
245 from Components.NimManager import nimmanager
246 from Components.About import about
249 result = popen(cmd, "r").read().strip()
254 "kernel : %s\n"%(command("uname -a"))
255 ,"version : %s (%s)\n"%(str(about.getImageVersionString()), str(about.getEnigmaVersionString()))
256 ,"frontprocessor : %s\n"%(str(getFPVersion()))
257 ,"frontend : %s\n"%(str(nimmanager.nimList()))
258 ,"hdd info : %s\n"%(str(harddiskmanager.HDDList()))
259 ,"network information : \n%s\n"%(command("ifconfig -a"))
261 f = open("/tmp/machine.info", 'w')
262 f.writelines(information)
266 def autosubmit(reason, **kwargs):
267 global g_default_activation
268 global g_default_aftersummit
269 global g_default_username
270 global g_default_useremail
272 print "[CrashReport] auto submit"
275 def isExistCrashlog(d='/media/hdd'):
277 for f in os.listdir(d):
278 if f.startswith("enigma2_crash_") and f.endswith(".log"):
284 def cbDataAvail(ret_data):
286 def cbAppClosed(retval):
287 if os.path.exists("/tmp/machine.info"):
288 os.system("rm -f /tmp/machine.info")
290 if "session" in kwargs:
291 if isExistCrashlog() == False:
292 print "[CrashReport] no crash-log"
294 session = kwargs["session"]
295 if g_default_activation == "send_summit":
298 sender = eConsoleAppContainer()
299 sender.dataAvail.append(cbDataAvail)
300 sender.appClosed.append(cbAppClosed)
302 if g_default_username == "":
305 un = g_default_username
306 if g_default_useremail == "":
307 um = "yourmail@here.is"
309 um = g_default_useremail
310 if g_default_machineinfo:
311 generateInformation()
313 sender.execute(_("python %s %s %s %s" % (g_senderfile, um, un.replace(" ", "_"), g_default_aftersummit)))
315 def Plugins(**kwargs):
316 return [PluginDescriptor(where = [PluginDescriptor.WHERE_SESSIONSTART], needsRestart = False, fnc = autosubmit),
317 PluginDescriptor(name=_("CrashlogReportSetting"), description=_("CrashlogReport setting"),where=PluginDescriptor.WHERE_MENU, needsRestart = False, fnc=opensetting)]