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
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 name="CrashlogReportSetting" position="209,48" size="865,623" title="CrashlogReport Setting" flags="wfNoBorder" backgroundColor="transparent">
84 <ePixmap pixmap="Vu_HD/Bg_EPG_list.png" zPosition="-1" position="0,0" size="865,623" alphatest="on" />
85 <ePixmap pixmap="Vu_HD/menu/ico_title_Setup.png" position="32,41" size="40,40" alphatest="blend" transparent="1" />
86 <eLabel text="CrashlogReport Setting" position="90,50" size="600,32" font="Semiboldit;32" foregroundColor="#5d5d5d" backgroundColor="#27b5b9bd" transparent="1" />
87 <ePixmap pixmap="Vu_HD/icons/clock.png" position="750,55" zPosition="1" size="20,20" alphatest="blend" />
88 <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">
89 <convert type="ClockToText">Format:%H:%M</convert>
91 <ePixmap pixmap="Vu_HD/buttons/red.png" position="45,98" size="25,25" alphatest="blend" />
92 <ePixmap pixmap="Vu_HD/buttons/green.png" position="240,98" size="25,25" alphatest="blend" />
93 <ePixmap pixmap="Vu_HD/buttons/button_off.png" position="435,98" size="25,25" alphatest="blend" />
94 <ePixmap pixmap="Vu_HD/buttons/button_off.png" position="630,98" size="25,25" alphatest="blend" />
95 <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" />
96 <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" />
97 <widget name="config" zPosition="2" position="50,130" itemHeight="36" size="750,324" scrollbarMode="showOnDemand" transparent="1" />
98 <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"/>
99 <widget name="VKeyIcon" pixmap="Vu_HD/buttons/key_text.png" position="500,350" zPosition="10" size="35,25" transparent="1" alphatest="on" />
100 <widget name="HelpWindow" pixmap="Vu_HD/vkey_icon.png" position="310,400" zPosition="1" size="1,1" transparent="1" alphatest="on" />
103 def __init__(self, session):
104 Screen.__init__(self, session)
105 self.session = session
107 self["shortcuts"] = ActionMap(["ShortcutActions", "SetupActions" ],
110 "cancel": self.keyCancel,
111 "red": self.keyCancel,
114 self["VirtualKB"] = ActionMap(["VirtualKeyboardActions" ],
116 "showVirtualKeyboard": self.cbSetTitle,
120 ConfigListScreen.__init__(self, self.list, session=self.session)
121 self["key_red"] = StaticText(_("Close"))
122 self["key_green"] = StaticText(_("Save"))
123 self["status"] = StaticText(" ")
124 self["VKeyIcon"] = Pixmap()
125 self["HelpWindow"] = Pixmap()
127 self["VKeyIcon"].hide()
128 self["VirtualKB"].setEnabled(False)
133 def initGlobal(self):
134 global g_default_activation
135 global g_default_aftersummit
136 global g_default_optionalinfo
137 global g_default_username
138 global g_default_useremail
139 global g_default_machineinfo
140 if g_default_activation == "":
141 g_default_activation = "send_summit"
142 if g_default_aftersummit == "":
143 g_default_aftersummit = "rename"
144 g_default_optionalinfo
145 if g_default_username == "":
146 g_default_username = "Vuplus User"
147 if g_default_useremail == "":
148 g_default_useremail = "yourmail@here.is"
149 self.g_activation = ConfigSelection(default=g_default_activation, choices=[("send_summit", _("Enable")), ("send_disable", _("Disable"))])
150 self.g_aftersummit = ConfigSelection(default=g_default_aftersummit, choices=[("rename", _("Rename")), ("delete", _("Delete"))])
151 self.g_optionalinfo = ConfigYesNo(default = g_default_optionalinfo)
152 self.g_username = ConfigText(default = g_default_username, fixed_size = False)
153 self.g_useremail = ConfigText(default = g_default_useremail, fixed_size = False)
154 self.g_machineinfo = ConfigYesNo(default = g_default_machineinfo)
156 self._activation = getConfigListEntry(_("Activation mode"), self.g_activation)
157 self._after_action = getConfigListEntry(_("Action after summit"), self.g_aftersummit)
158 self._add_user_info = getConfigListEntry(_("Include optional infomation"), self.g_optionalinfo)
159 self._user_info_name = getConfigListEntry(_("User name"), self.g_username)
160 self._user_info_mail = getConfigListEntry(_("User Email"), self.g_useremail)
161 self._machineinfo = getConfigListEntry(_("Include settop information"), self.g_machineinfo)
163 if not self.cbSelectionChanged in self["config"].onSelectionChanged:
164 self["config"].onSelectionChanged.append(self.cbSelectionChanged)
168 self.list.append(self._activation)
169 if self.g_activation.value == "send_summit":
170 self.list.append(self._after_action)
171 self.list.append(self._add_user_info)
172 if self.g_optionalinfo.value:
173 self.list.append(self._user_info_name)
174 self.list.append(self._user_info_mail)
175 self.list.append(self._machineinfo)
176 self["config"].list = self.list
177 self["config"].l.setList(self.list)
180 if self["config"].getCurrent() == self._activation or self["config"].getCurrent() == self._add_user_info:
183 def cbSelectionChanged(self):
184 current = self["config"].getCurrent()
185 if current == self._activation:
186 self.enableVKIcon(False)
187 elif current == self._after_action:
188 self.enableVKIcon(False)
189 elif current == self._add_user_info:
190 self.enableVKIcon(False)
191 elif current == self._user_info_name:
192 self.enableVKIcon(True)
193 elif current == self._user_info_mail:
194 self.enableVKIcon(True)
195 elif current == self._machineinfo:
196 self.enableVKIcon(False)
198 def cbSetTitle(self):
200 if self["config"].getCurrent() == self._user_info_mail:
201 t = "Please enter user email:"
202 if self["config"].getCurrent() == self._user_info_name:
203 t = "Please enter user name:"
204 self.session.openWithCallback(self.NameCallback, VirtualKeyBoard, title = (t), text = self._user_info_name.value)
206 def enableVKIcon(self, mode):
208 self["VKeyIcon"].show()
210 self["VKeyIcon"].hide()
211 self["VirtualKB"].setEnabled(True)
213 def saveConfig(self):
214 if self.g_optionalinfo.value:
215 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)
217 saveConfig(self.g_activation.value, self.g_aftersummit.value, self.g_machineinfo.value, self.g_optionalinfo.value)
220 ConfigListScreen.keyLeft(self)
224 ConfigListScreen.keyRight(self)
233 if os.path.exists(g_configfile) == False:
237 def main(session, **kwargs):
239 session.open(CrashlogReportConfiguration)
241 def opensetting(menuid, **kwargs):
242 if menuid != "system":
244 return [(_("Crashlog Reporting"), main, "crashlog_configure", 70)]
246 def generateInformation():
248 from Tools.DreamboxHardware import getFPVersion
249 from Components.Harddisk import harddiskmanager
250 from Components.NimManager import nimmanager
251 from Components.About import about
254 result = popen(cmd, "r").read().strip()
259 "kernel : %s\n"%(command("uname -a"))
260 ,"version : %s (%s)\n"%(str(about.getImageVersionString()), str(about.getEnigmaVersionString()))
261 ,"frontprocessor : %s\n"%(str(getFPVersion()))
262 ,"frontend : %s\n"%(str(nimmanager.nimList()))
263 ,"hdd info : %s\n"%(str(harddiskmanager.HDDList()))
264 ,"network information : \n%s\n"%(command("ifconfig -a"))
266 f = open("/tmp/machine.info", 'w')
267 f.writelines(information)
271 def autosubmit(reason, **kwargs):
272 global g_default_activation
273 global g_default_aftersummit
274 global g_default_username
275 global g_default_useremail
277 print "[CrashReport] auto submit"
280 def isExistCrashlog(d='/media/hdd'):
282 for f in os.listdir(d):
283 if f.startswith("enigma2_crash_") and f.endswith(".log"):
289 def cbDataAvail(ret_data):
291 def cbAppClosed(retval):
292 if os.path.exists("/tmp/machine.info"):
293 os.system("rm -f /tmp/machine.info")
295 if "session" in kwargs:
296 if isExistCrashlog() == False:
297 print "[CrashReport] no crash-log"
299 session = kwargs["session"]
300 if g_default_activation == "send_summit":
303 sender = eConsoleAppContainer()
304 sender.dataAvail.append(cbDataAvail)
305 sender.appClosed.append(cbAppClosed)
307 if g_default_username == "":
310 un = g_default_username
311 if g_default_useremail == "":
312 um = "yourmail@here.is"
314 um = g_default_useremail
315 if g_default_machineinfo:
316 generateInformation()
318 sender.execute(_("python %s %s %s %s" % (g_senderfile, um, un.replace(" ", "_"), g_default_aftersummit)))
320 def Plugins(**kwargs):
321 return [PluginDescriptor(where = [PluginDescriptor.WHERE_SESSIONSTART], needsRestart = False, fnc = autosubmit),
322 PluginDescriptor(name=_("CrashlogReportSetting"), description=_("CrashlogReport setting"),where=PluginDescriptor.WHERE_MENU, needsRestart = False, fnc=opensetting)]