diff options
author | René 'Necoro' Neumann <necoro@necoro.net> | 2010-04-09 23:43:44 +0200 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.net> | 2010-04-09 23:43:44 +0200 |
commit | d8c4bacde00e2be0e5d5aaf7f85f139aae6a95d6 (patch) | |
tree | 12f088e6c07b690cccbcc073b744dc5760713918 /portato/gui/windows | |
parent | 3cc84485184c1662fabb53f35df43a539021ff93 (diff) | |
parent | 359309950a1283dbbf9df6ce1085838087cfc262 (diff) | |
download | portato-d8c4bacde00e2be0e5d5aaf7f85f139aae6a95d6.tar.gz portato-d8c4bacde00e2be0e5d5aaf7f85f139aae6a95d6.tar.bz2 portato-d8c4bacde00e2be0e5d5aaf7f85f139aae6a95d6.zip |
Merge branch 'master' into no_config to pickup the recent changes andno_config
fixes.
Conflicts:
portato/db/__init__.py
portato/session.py
Diffstat (limited to '')
-rw-r--r-- | portato/gui/windows/about.py | 8 | ||||
-rw-r--r-- | portato/gui/windows/basic.py | 3 | ||||
-rw-r--r-- | portato/gui/windows/mailinfo.py | 137 | ||||
-rw-r--r-- | portato/gui/windows/main.py | 19 |
4 files changed, 133 insertions, 34 deletions
diff --git a/portato/gui/windows/about.py b/portato/gui/windows/about.py index a15fd24..0d2ce1a 100644 --- a/portato/gui/windows/about.py +++ b/portato/gui/windows/about.py @@ -10,12 +10,13 @@ # # Written by René 'Necoro' Neumann <necoro@necoro.net> -from __future__ import absolute_import +from __future__ import absolute_import, with_statement +import os import gtk from .basic import AbstractDialog -from ...constants import VERSION, REVISION +from ...constants import VERSION, REVISION, DATA_DIR class AboutWindow (AbstractDialog): """A window showing the "about"-informations.""" @@ -27,6 +28,9 @@ class AboutWindow (AbstractDialog): self.window.set_version(VERSION) self.window.set_logo(None) + with open(os.path.join(DATA_DIR, "TRANSLATORS")) as f: + self.window.set_translator_credits("".join(f.readlines())) + if REVISION: gitlabel = self.tree.get_widget("gitLabel") gitlabel.set_label(REVISION) diff --git a/portato/gui/windows/basic.py b/portato/gui/windows/basic.py index 92c35f4..01d31e5 100644 --- a/portato/gui/windows/basic.py +++ b/portato/gui/windows/basic.py @@ -151,6 +151,9 @@ class AbstractDialog (Window): self.window.set_transient_for(parent) self.parent = parent + # type hint + self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG) + # catch the ESC-key self.window.connect("key-press-event", self.cb_key_pressed) diff --git a/portato/gui/windows/mailinfo.py b/portato/gui/windows/mailinfo.py index 0ee232a..4367482 100644 --- a/portato/gui/windows/mailinfo.py +++ b/portato/gui/windows/mailinfo.py @@ -14,34 +14,98 @@ from __future__ import absolute_import, with_statement import smtplib, socket import time +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 +from .. import dialogs from ...helper import debug, info -from ...constants import VERSION +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): + gtk.Dialog.__init__(self, f, parent, buttons = (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)) + + textview = gtk.TextView() + textview.set_editable(False) + textview.modify_font(pango.FontDescription("Monospace")) + textview.set_size_request(gtk.gdk.screen_width()/2, gtk.gdk.screen_height()/3) + + sw = gtk.ScrolledWindow(); + sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) + sw.add(textview) + + self.vbox.add(sw) + + textbuffer = textview.get_buffer() + + with open(f) as text: + textbuffer.set_text(text.read()) + + self.vbox.show_all() class MailInfoWindow (AbstractDialog): - TO = "bugs@portato.necoro.net" + TO = "bugs@necoro.eu" def __init__ (self, parent, tb): AbstractDialog.__init__(self, parent) + + self.files = [LOGFILE, CONFIG_LOCATION] + [s._file for s in session.sessionlist] + self.fileList = self.tree.get_widget("fileList") + self.build_file_list() + self.mailEntry = self.tree.get_widget("mailEntry") self.tb = tb self.window.show_all() + def build_file_list(self): + store = gtk.ListStore(bool, str) + + for f in self.files: + store.append((True, f)) + + self.fileList.set_model(store) + cell = gtk.CellRendererText() + tCell = gtk.CellRendererToggle() + tCell.set_property("activatable", True) + tCell.connect("toggled", self.cb_file_toggled) + + self.fileList.append_column(gtk.TreeViewColumn(None, tCell, active = 0)) + self.fileList.append_column(gtk.TreeViewColumn(None, cell, text = 1)) + + def cb_file_toggled(self, cell, path): + store = self.fileList.get_model() + store[path][0] = not store[path][0] + return True + + def cb_file_clicked(self, view, path, *args): + store = view.get_model() + f = store[path][1] + + dialog = ShowDialog(self.window, f) + dialog.run() + dialog.destroy() + def set_data (self): 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() - self.addr = self.tree.get_widget("mailEntry").get_text() + self.addr = self.mailEntry.get_text() if not self.addr: self.addr = self.TO @@ -63,40 +127,61 @@ class MailInfoWindow (AbstractDialog): 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') + # logs + for (active, f) in self.fileList.get_model(): + if active: + debug("Attaching '%s'", f) + with open(f, "r") as text: + log = MIMEText(text.read(), "plain", "utf-8") + log.add_header('Content-Disposition', 'attachment', filename=basename(f)) - self.message.attach(log) + self.message.attach(log) 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 + 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: - 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.as_string()) - debug("Sent") - finally: - server.quit() + if e.recipients[self.TO][0] < 500: + info(_("An error occurred while sending. I think we were greylisted. The error: %s") % e) + 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): - self.set_data() - GtkThread(target = self.send, name = "Mail Send Thread").start() - self.close() + 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() + else: + self.window.present() + self.mailEntry.grab_focus() + return True diff --git a/portato/gui/windows/main.py b/portato/gui/windows/main.py index cd4cf24..2f5b48e 100644 --- a/portato/gui/windows/main.py +++ b/portato/gui/windows/main.py @@ -1434,8 +1434,8 @@ class MainWindow (Window): """Execute the current queue.""" if len(flags.newUseFlags) > 0: - if not self.session.get_boolean("useflags", "dialogs"): - self.session.set("useflags", dialogs.changed_flags_dialog(_("use flags"))[1], "dialogs") + if not self.session.get_bool("useflags", "dialogs"): + self.session.set("useflags", str(dialogs.changed_flags_dialog(_("use flags"))[1]), "dialogs") try: flags.write_use_flags() except IOError, e: @@ -1446,8 +1446,8 @@ class MainWindow (Window): debug("new masked: %s",flags.new_masked) debug("new unmasked: %s", flags.new_unmasked) debug("new testing: %s", flags.newTesting) - if not self.session.get_boolean("keywords", "dialogs"): - self.session.set("keywords", dialogs.changed_flags_dialog(_("masking keywords"))[1], "dialogs") + if not self.session.get_bool("keywords", "dialogs"): + self.session.set("keywords", str(dialogs.changed_flags_dialog(_("masking keywords"))[1]), "dialogs") try: flags.write_masked() flags.write_testing() @@ -1511,8 +1511,15 @@ class MainWindow (Window): gobject.idle_add(cb_idle_append, updating) finally: self.window.window.set_cursor(None) - - GtkThread(name="Update-Thread", target=__update).start() + + # for some reason, I have to create the thread before displaying the dialog + # else the GUI hangs + t = GtkThread(name="Update-Thread", target=__update) + + if not self.session.get_bool("update_world_warning", "dialogs"): + self.session.set("update_world_warning", str(dialogs.update_world_warning_dialog()[1]), "dialogs") + + t.start() return True |