From 5a52259b1404727718f57d44b266820542b9f1e6 Mon Sep 17 00:00:00 2001 From: René 'Necoro' Neumann Date: Fri, 26 Mar 2010 22:37:12 +0100 Subject: Fixed mailinfo window --- portato/gui/windows/mailinfo.py | 58 +++++++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 20 deletions(-) (limited to 'portato/gui') diff --git a/portato/gui/windows/mailinfo.py b/portato/gui/windows/mailinfo.py index c5002e7..4367482 100644 --- a/portato/gui/windows/mailinfo.py +++ b/portato/gui/windows/mailinfo.py @@ -14,19 +14,23 @@ from __future__ import absolute_import, with_statement import smtplib, socket import time -import gtk, pango +import gtk, pango, gobject from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from os.path import basename from .basic import AbstractDialog from ..utils import GtkThread -from ..dialogs import mail_failure_dialog, no_email_dialog +from .. import dialogs from ...helper import debug, info from ...constants import VERSION, CONFIG_LOCATION from ...log import LOGFILE from ... import session +def mail_failure_dialog(*a): + dialogs.mail_failure_dialog(*a) + return False + class ShowDialog (gtk.Dialog): def __init__(self, parent, f): @@ -51,7 +55,7 @@ class ShowDialog (gtk.Dialog): self.vbox.show_all() class MailInfoWindow (AbstractDialog): - TO = "bugs@portato.necoro.net" + TO = "bugs@necoro.eu" def __init__ (self, parent, tb): @@ -97,6 +101,7 @@ class MailInfoWindow (AbstractDialog): self.message = MIMEMultipart() self.message["Subject"] = "[Bug Report] Bug in Portato %s" % VERSION self.message["To"] = self.TO + self.message["X-Portato-Version"] = VERSION # TO and FROM name = self.tree.get_widget("nameEntry").get_text() @@ -134,31 +139,44 @@ class MailInfoWindow (AbstractDialog): def send (self): try: - debug("Connecting to server") - server = smtplib.SMTP("mail.necoro.eu") - debug("Sending mail") - try: - for i in range(5): # try 5 times at max - try: - server.sendmail(self.addr, self.TO, self.message.as_string()) - except smtplib.SMTPRecipientsRefused, e: + for i in range(5): # try 5 times at max + if i > 0: + info(_("Retrying after waiting %d seconds."), 300) + time.sleep(300) + try: + debug("Connecting to server") + server = smtplib.SMTP("mail.necoro.eu") + debug("Sending mail") + + if smtplib._have_ssl: server.starttls() + else: debug("TLS not supported in Python. Continuing without it.") + + server.sendmail(self.addr, self.TO, self.message.as_string()) + except smtplib.SMTPRecipientsRefused, e: + if e.recipients[self.TO][0] < 500: info(_("An error occurred while sending. I think we were greylisted. The error: %s") % e) - info(_("Retrying after waiting %d seconds."), 30) - time.sleep(30) - else: - debug("Sent") - break - finally: - server.quit() + else: raise + else: + debug("Sent") + break + finally: + try: + server.quit() + except smtplib.SMTPServerDisconnected: + pass # ignore this except socket.error, e: - mail_failure_dialog("%s (Code: %s)" % (e.args[1], e.args[0])) + gobject.idle_add(mail_failure_dialog, "%s (Code: %s)" % (e.args[1], e.args[0])) + except smtplib.SMTPResponseException, e: + gobject.idle_add(mail_failure_dialog, "%s (Code: %s)" % (e.smtp_error, e.smtp_code)) + except smtplib.SMTPException, e: + gobject.idle_add(mail_failure_dialog, e.args) def cb_cancel_clicked (self, *args): self.close() return True def cb_send_clicked (self, *args): - if self.mailEntry.get_text() or no_email_dialog(self.window) == gtk.RESPONSE_OK: + if self.mailEntry.get_text() or dialogs.no_email_dialog(self.window) == gtk.RESPONSE_OK: self.set_data() GtkThread(target = self.send, name = "Mail Send Thread").start() self.close() -- cgit v1.2.3-54-g00ecf +0200'>2010-04-23Clearer debug message for packages not in mergequeueRené 'Necoro' Neumann1-1/+1 2010-04-23Reset HOME to /root for rootRené 'Necoro' Neumann1-0/+4 2010-04-23Small error in sqldbRené 'Necoro' Neumann1-1/+1 2010-04-22Updated french translation to current translation status.Clement Bourgeois1-77/+84 2010-04-19Typo in TRANSLATORSRené 'Necoro' Neumann1-1/+1 2010-04-19Updated portguese translationAlberto Federman Neto1-348/+469 2010-04-19Remove unused pythonic eix parser implementationRené 'Necoro' Neumann1-416/+0 2010-04-19Connect the accels from the menu.René 'Necoro' Neumann1-12/+16 2010-04-19Replace 'Portage Warning' by 'External Warning'René 'Necoro' Neumann1-1/+1 2010-04-17Updated italian translation. Thx to PonsiRené 'Necoro' Neumann1-314/+369 2010-04-16Fix gtk deprecation warningRené 'Necoro' Neumann1-1/+1 2010-04-16TypoRené 'Necoro' Neumann2-3/+3 2010-04-16Do not allow portage's sqlite backend for the moment ... bug #564292René 'Necoro' Neumann2-16/+25 2010-04-15Better sorting of the database types in the preferences.René 'Necoro' Neumann2-6/+6 2010-04-15Add notify-python dependency for the version checkerRené 'Necoro' Neumann1-1/+1 2010-04-15Make the database type choice an info messageRené 'Necoro' Neumann2-7/+13 2010-04-15Renamed es_ES to esRené 'Necoro' Neumann1-0/+0 2010-04-15Fixed dependancy of the new_version plugin from "dev-util/git" to "dev-vcs/gi...Clement Bourgeois1-1/+1 2010-04-14Make some useless info messages being debug statementsRené 'Necoro' Neumann2-34/+17 2010-04-14Improve the C modulesRené 'Necoro' Neumann3-37/+52 2010-04-14Small modifications made to the French translation (typos, grammar).Clement Bourgeois1-69/+69 2010-04-14Fixed the unicode support and stuff ... and also made eix faster :)René 'Necoro' Neumann1-20/+22 2010-04-14Disable debug messages by defaultRené 'Necoro' Neumann1-1/+1 2010-04-13Better eix error inheritance and handlingRené 'Necoro' Neumann1-2/+9 2010-04-13Fix the handling of FilterSets. Fixes bug #558887.René 'Necoro' Neumann2-56/+64 2010-04-12Updated newsRené 'Necoro' Neumann1-0/+1 2010-04-13Added my name to translators list.Clement Bourgeois1-0/+1