aboutsummaryrefslogtreecommitdiff
path: root/lib/python
diff options
context:
space:
mode:
authorFelix Domke <felix.domke@multimedia-labs.de>2009-08-14 13:23:54 +0200
committerFelix Domke <felix.domke@multimedia-labs.de>2009-08-14 13:23:54 +0200
commit29c3340e877cfa1d1818a140f76f14270b84c3d2 (patch)
treeae02bbd3ff630338c701b76af62daf7fdec4a8d5 /lib/python
parentdf505deaccfced52c34c620e367b8659a0ec6fbd (diff)
parentdf662e86097ac84a001a1fd8c20e0a8454acd103 (diff)
downloadenigma2-29c3340e877cfa1d1818a140f76f14270b84c3d2.tar.gz
enigma2-29c3340e877cfa1d1818a140f76f14270b84c3d2.zip
Merge branch 'master' of git.opendreambox.org:/git/enigma2
Diffstat (limited to 'lib/python')
-rwxr-xr-xlib/python/Plugins/SystemPlugins/CrashlogAutoSubmit/plugin.py65
-rw-r--r--lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py35
-rw-r--r--lib/python/Screens/Standby.py11
3 files changed, 82 insertions, 29 deletions
diff --git a/lib/python/Plugins/SystemPlugins/CrashlogAutoSubmit/plugin.py b/lib/python/Plugins/SystemPlugins/CrashlogAutoSubmit/plugin.py
index e58f19a0..dca75af1 100755
--- a/lib/python/Plugins/SystemPlugins/CrashlogAutoSubmit/plugin.py
+++ b/lib/python/Plugins/SystemPlugins/CrashlogAutoSubmit/plugin.py
@@ -12,6 +12,7 @@ from enigma import ePoint
import os
from twisted.mail import smtp, relaymanager
+import MimeWriter, mimetools, StringIO
config.plugins.crashlogautosubmit = ConfigSubsection()
config.plugins.crashlogautosubmit.sendmail = ConfigSelection(default = "send", choices = [
@@ -219,13 +220,28 @@ class CrashlogAutoSubmitConfiguration(Screen, ConfigListScreen):
def mxServerFound(mxServer,session):
print "[CrashlogAutoSubmit] - mxServerFound -->", mxServer
- attachments = []
crashLogFilelist = []
+ message = StringIO.StringIO()
+ writer = MimeWriter.MimeWriter(message)
mailFrom = "enigma2@crashlog.dream-multimedia-tv.de"
mailTo = "enigma2@crashlog.dream-multimedia-tv.de"
subject = "Automatically generated crashlogmail"
- mailtext = "\nHello\n\nHere are some crashlogs i found for you.\n"
- mailfooter = "\n\nThis is an automatically generated email from the CrashlogAutoSubmit plugin.\n\n\nHave a nice day.\n"
+ # Define the main body headers.
+ writer.addheader('To', "dream-multimedia-crashlogs <enigma2@crashlog.dream-multimedia-tv.de>")
+ writer.addheader('From', "CrashlogAutoSubmitter <enigma2@crashlog.dream-multimedia-tv.de>")
+ writer.addheader('Subject', str(subject))
+ writer.addheader('Date', smtp.rfc822date())
+ if config.plugins.crashlogautosubmit.attachemail.value is True:
+ if str(config.plugins.crashlogautosubmit.email.value) != "myemail@home.com":
+ writer.addheader('Reply-To', str(str(config.plugins.crashlogautosubmit.email.value)))
+ writer.addheader('MIME-Version', '1.0')
+ writer.startmultipartbody('mixed')
+ # start with a text/plain part
+ part = writer.nextpart()
+ body = part.startbody('text/plain')
+ part.flushheaders()
+ # Define the message body
+ body_text1 = "\nHello\n\nHere are some crashlogs i found for you.\n"
if str(config.plugins.crashlogautosubmit.email.value) == "myemail@home.com":
user_email = ""
else:
@@ -234,11 +250,9 @@ def mxServerFound(mxServer,session):
user_name = ""
else:
user_name = "\n\nOptional supplied name: " + str(config.plugins.crashlogautosubmit.name.value)
- headers = { 'from': 'CrashlogAutoSubmitter <enigma2@crashlog.dream-multimedia-tv.de>', 'to': 'dream-multimedia-crashlogs <enigma2@crashlog.dream-multimedia-tv.de>', 'subject' : str(subject) }
- mailData = mailtext + user_email + user_name + mailfooter
- if config.plugins.crashlogautosubmit.attachemail.value is True:
- if str(config.plugins.crashlogautosubmit.email.value) != "myemail@home.com":
- headers["reply-to"] = str(config.plugins.crashlogautosubmit.email.value)
+ body_text2 = "\n\nThis is an automatically generated email from the CrashlogAutoSubmit plugin.\n\n\nHave a nice day.\n"
+ body_text = body_text1 + user_email + user_name + body_text2
+ body.write(body_text)
list = (
(_("Yes"), "send"),
@@ -263,16 +277,17 @@ def mxServerFound(mxServer,session):
def send_mail():
print "[CrashlogAutoSubmit] - send_mail"
- attachments = []
if len(crashLogFilelist):
for crashlog in crashLogFilelist:
filename = str(os.path.basename(crashlog))
- mimetype = "text/plain"
- f = open (crashlog, 'r')
- attachment = str(f.read())
- f.close()
- attachments.append ((filename,mimetype,attachment))
- sending = smtp.sendEmail(str(mxServer), mailFrom, mailTo, str(mailData), headers, attachments)
+ subpart = writer.nextpart()
+ subpart.addheader("Content-Transfer-Encoding", 'base64')
+ subpart.addheader("Content-Disposition",'attachment; filename="%s"' % filename)
+ subpart.addheader('Content-Description', 'Enigma2 crashlog')
+ body = subpart.startbody("%s; name=%s" % ('application/octet-stream', filename))
+ mimetools.encode(open(crashlog, 'rb'), body, 'base64')
+ writer.lastpart()
+ sending = smtp.sendmail(str(mxServer), mailFrom, mailTo, message.getvalue())
sending.addCallback(handleSuccess).addErrback(handleError)
def handleAnswer(answer):
@@ -296,7 +311,6 @@ def mxServerFound(mxServer,session):
elif answer == "send_not":
print "[CrashlogAutoSubmit] - not sending crashlogs for this time."
-
for crashlog in os.listdir('/media/hdd'):
if crashlog.startswith("enigma2_crash_") and crashlog.endswith(".log"):
print "[CrashlogAutoSubmit] - found crashlog: ",os.path.basename(crashlog)
@@ -313,14 +327,10 @@ def mxServerFound(mxServer,session):
def getMailExchange(host):
print "[CrashlogAutoSubmit] - getMailExchange"
+ return relaymanager.MXCalculator().getMX(host).addCallback(_gotMXRecord)
- def handleMXError(error):
- print "[CrashlogAutoSubmit] - DNS-Error, sending aborted -->", error.getErrorMessage()
-
- def cbMX(mxRecord):
- return str(mxRecord.name)
-
- return relaymanager.MXCalculator().getMX(host).addCallback(cbMX).addErrback(handleMXError)
+def _gotMXRecord(mxRecord):
+ return str(mxRecord.name)
def startMailer(session):
@@ -328,8 +338,15 @@ def startMailer(session):
print "[CrashlogAutoSubmit] - not starting CrashlogAutoSubmit"
return False
+ def gotMXServer(mxServer):
+ print "[CrashlogAutoSubmit] gotMXServer: ",mxServer
+ mxServerFound(mxServer,session)
+
+ def handleMXError(error):
+ print "[CrashlogAutoSubmit] - MX resolve ERROR:", error.getErrorMessage()
+
if not config.misc.firstrun.value:
- getMailExchange('crashlog.dream-multimedia-tv.de').addCallback(mxServerFound,session)
+ getMailExchange('crashlog.dream-multimedia-tv.de').addCallback(gotMXServer).addErrback(handleMXError)
def callCrashMailer(result,session):
diff --git a/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py b/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py
index 6292a46f..ba668f8b 100644
--- a/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py
+++ b/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py
@@ -9,6 +9,7 @@ from Components.Sources.Progress import Progress
from Components.Label import Label
from Components.FileList import FileList
from Components.MultiContent import MultiContentEntryText
+from Components.ScrollLabel import ScrollLabel
from Tools.Directories import fileExists
from Tools.HardwareInfo import HardwareInfo
from enigma import eConsoleAppContainer, eListbox, gFont, eListboxPythonMultiContent, \
@@ -62,6 +63,34 @@ class Feedlist(MenuList):
if self.instance is not None:
self.instance.moveSelectionTo(idx)
+class NFOViewer(Screen):
+ skin = """
+ <screen name="NFOViewer" position="110,115" size="540,400" title="Changelog viewer" >
+ <widget name="changelog" position="10,10" size="520,380" font="Regular;16" />
+ </screen>"""
+
+ def __init__(self, session, nfo):
+ Screen.__init__(self, session)
+ self["changelog"] = ScrollLabel(nfo)
+
+ self["ViewerActions"] = ActionMap(["SetupActions", "ColorActions", "DirectionActions"],
+ {
+ "green": self.exit,
+ "red": self.exit,
+ "ok": self.exit,
+ "cancel": self.exit,
+ "down": self.pageDown,
+ "up": self.pageUp
+ })
+ def pageUp(self):
+ self["changelog"].pageUp()
+
+ def pageDown(self):
+ self["changelog"].pageDown()
+
+ def exit(self):
+ self.close(False)
+
class NFIDownload(Screen):
LIST_SOURCE = 1
LIST_DEST = 2
@@ -230,6 +259,8 @@ class NFIDownload(Screen):
self["destlist"].pageDown()
def ok(self):
+ if self.focus is self.LIST_SOURCE and self.nfo:
+ self.session.open(NFOViewer, self.nfo)
if self.download:
return
if self.focus is self.LIST_DEST:
@@ -249,7 +280,7 @@ class NFIDownload(Screen):
def feed_finished(self, feedhtml):
print "[feed_finished] " + str(feedhtml)
self.downloading(False)
- fileresultmask = re.compile("<a href=[\'\"](?P<url>.*?)[\'\"]>(?P<name>.*?.nfi)</a>", re.DOTALL)
+ fileresultmask = re.compile("<a class=[\'\"]nfi[\'\"] href=[\'\"](?P<url>.*?)[\'\"]>(?P<name>.*?.nfi)</a>", re.DOTALL)
searchresults = fileresultmask.finditer(feedhtml)
fileresultlist = []
if searchresults:
@@ -308,7 +339,7 @@ class NFIDownload(Screen):
else:
self.nfofilename = ""
self["infolabel"].text = _("No details for this image file")
- self["statusbar"].text = ""
+ self["statusbar"].text = _("Press OK to view full changelog")
def nfi_download(self):
if self["destlist"].getCurrentDirectory() is None:
diff --git a/lib/python/Screens/Standby.py b/lib/python/Screens/Standby.py
index 8314e213..b8ccb6c2 100644
--- a/lib/python/Screens/Standby.py
+++ b/lib/python/Screens/Standby.py
@@ -162,9 +162,14 @@ class TryQuitMainloop(MessageBox):
self.conntected=False
self.session.nav.record_event.remove(self.getRecordEvent)
if value:
- quitMainloop(self.retval)
- else:
- MessageBox.close(self, True)
+ # hack .. we dont like to show any other screens when this screen has closed
+ self.onClose = [self.__closed]
+ self.session.dialog_stack = []
+ self.session.summary_stack = [None]
+ MessageBox.close(self, True)
+
+ def __closed(self):
+ quitMainloop(self.retval)
def __onShow(self):
global inTryQuitMainloop