diff options
Diffstat (limited to '')
-rw-r--r-- | portato/gui/templates/MailInfoWindow.glade | 24 | ||||
-rw-r--r-- | portato/gui/windows/mailinfo.py | 40 |
2 files changed, 48 insertions, 16 deletions
diff --git a/portato/gui/templates/MailInfoWindow.glade b/portato/gui/templates/MailInfoWindow.glade index a01f652..11ef33a 100644 --- a/portato/gui/templates/MailInfoWindow.glade +++ b/portato/gui/templates/MailInfoWindow.glade @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd"> -<!--Generated with glade3 3.4.5 on Thu Jul 10 20:05:27 2008 --> +<!--Generated with glade3 3.4.5 on Mon Sep 15 20:20:19 2008 --> <glade-interface> <widget class="GtkWindow" id="MailInfoWindow"> <property name="title" translatable="yes">Send Bug Mail ...</property> @@ -19,10 +19,13 @@ <child> <widget class="GtkTable" id="table1"> <property name="visible">True</property> - <property name="n_rows">4</property> + <property name="n_rows">5</property> <property name="n_columns">2</property> <property name="row_spacing">10</property> <child> + <placeholder/> + </child> + <child> <widget class="GtkLabel" id="label3"> <property name="visible">True</property> <property name="label" translatable="yes"><b><u>Additional Information</u></b> @@ -132,6 +135,23 @@ what did you do to hit the bug?</property> <property name="x_padding">5</property> </packing> </child> + <child> + <widget class="GtkCheckButton" id="logCheck"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="tooltip" translatable="yes">Attaches the logfile to the mail. This log only contains debug information.</property> + <property name="label" translatable="yes">Attach _Logfile</property> + <property name="use_underline">True</property> + <property name="response_id">0</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> + <property name="x_options">GTK_FILL</property> + </packing> + </child> </widget> <packing> <property name="padding">5</property> diff --git a/portato/gui/windows/mailinfo.py b/portato/gui/windows/mailinfo.py index 22e750a..bbcbf1f 100644 --- a/portato/gui/windows/mailinfo.py +++ b/portato/gui/windows/mailinfo.py @@ -10,16 +10,19 @@ # # Written by René 'Necoro' Neumann <necoro@necoro.net> -from __future__ import absolute_import +from __future__ import absolute_import, with_statement import smtplib, socket import time +from email.mime.multipart import MIMEMultipart +from email.mime.text import MIMEText from .basic import AbstractDialog from ..utils import GtkThread from ..dialogs import mail_failure_dialog from ...helper import debug, info from ...constants import VERSION +from ...log import LOGFILE class MailInfoWindow (AbstractDialog): TO = "bugs@portato.necoro.net" @@ -32,17 +35,23 @@ class MailInfoWindow (AbstractDialog): self.window.show_all() def set_data (self): + self.message = MIMEMultipart() + self.message["Subject"] = "[Bug Report] Bug in Portato %s" % VERSION + self.message["To"] = self.TO + + # TO and FROM name = self.tree.get_widget("nameEntry").get_text() - addr = self.tree.get_widget("mailEntry").get_text() + self.addr = self.tree.get_widget("mailEntry").get_text() - if not addr: - addr = self.TO + if not self.addr: + self.addr = self.TO if name: - fro = "%s <%s>" % (name, addr) + self.message["From"] = "%s <%s>" % (name, self.addr) else: - fro = addr + self.message["From"] = self.addr + # text commentBuffer = self.tree.get_widget("commentEntry").get_buffer() text = commentBuffer.get_text(*commentBuffer.get_bounds()) @@ -51,13 +60,16 @@ class MailInfoWindow (AbstractDialog): text += self.tb - message = """From: %s -To: %s -Subject: %s -%s""" % ( fro, self.TO, ("[Bug Report] Bug in Portato %s" % VERSION), text) + txtmsg = MIMEText(text, "plain", "utf-8") + self.message.attach(txtmsg) + + # log + if self.tree.get_widget("logCheck").get_active(): + with open(LOGFILE, "r") as f: + log = MIMEText(f.read(), "plain", "utf-8") + log.add_header('Content-Disposition', 'attachment', filename='portato.log') - self.addr = addr - self.message = message + self.message.attach(log) def send (self): try: @@ -66,12 +78,12 @@ Subject: %s debug("Sending mail") try: try: - server.sendmail(self.addr, self.TO, self.message) + server.sendmail(self.addr, self.TO, self.message.as_string()) except smtplib.SMTPRecipientsRefused, e: info(_("An error occurred while sending. I think we were greylisted. The error: %s") % e) info(_("Retrying after waiting 60 seconds.")) time.sleep(60) - server.sendmail(self.addr, self.TO, self.message) + server.sendmail(self.addr, self.TO, self.message.as_string()) debug("Sent") finally: server.quit() |