diff options
Diffstat (limited to 'portato/gui')
-rw-r--r-- | portato/gui/__init__.py | 4 | ||||
-rw-r--r-- | portato/gui/exception_handling.py | 6 | ||||
-rw-r--r-- | portato/gui/queue.py | 14 | ||||
-rw-r--r-- | portato/gui/slots.py | 2 | ||||
-rw-r--r-- | portato/gui/updater.py | 4 | ||||
-rw-r--r-- | portato/gui/utils.py | 4 | ||||
-rw-r--r-- | portato/gui/views.py | 4 | ||||
-rw-r--r-- | portato/gui/windows/about.py | 2 | ||||
-rw-r--r-- | portato/gui/windows/basic.py | 2 | ||||
-rw-r--r-- | portato/gui/windows/mailinfo.py | 10 | ||||
-rw-r--r-- | portato/gui/windows/main.py | 45 | ||||
-rw-r--r-- | portato/gui/windows/pkglist.py | 6 | ||||
-rw-r--r-- | portato/gui/windows/plugin.py | 12 | ||||
-rw-r--r-- | portato/gui/windows/preference.py | 14 | ||||
-rw-r--r-- | portato/gui/windows/search.py | 2 | ||||
-rw-r--r-- | portato/gui/windows/splash.py | 2 |
16 files changed, 66 insertions, 67 deletions
diff --git a/portato/gui/__init__.py b/portato/gui/__init__.py index bbe21d8..63f5eb0 100644 --- a/portato/gui/__init__.py +++ b/portato/gui/__init__.py @@ -10,7 +10,7 @@ # # Written by René 'Necoro' Neumann <necoro@necoro.net> -from __future__ import absolute_import + from ..helper import error from .exception_handling import register_ex_handler @@ -31,7 +31,7 @@ def run (): del s m.main() - except PreReqError, e: + except PreReqError as e: error("Prerequisite not matched. Aborting.") prereq_error_dialog(e) s.destroy() diff --git a/portato/gui/exception_handling.py b/portato/gui/exception_handling.py index d9b133c..10b36fc 100644 --- a/portato/gui/exception_handling.py +++ b/portato/gui/exception_handling.py @@ -11,12 +11,12 @@ # # Written by René 'Necoro' Neumann -from __future__ import absolute_import, with_statement +from future_builtins import map, filter, zip import gtk, pango, gobject import sys, traceback -from StringIO import StringIO +from cStringIO import StringIO from ..helper import debug, error, get_runsystem from .dialogs import file_chooser_dialog, io_ex_dialog @@ -78,7 +78,7 @@ class UncaughtExceptionDialog(gtk.MessageDialog): try: with open(file, "w") as f: f.writelines(self.text) - except IOError, e: + except IOError as e: io_ex_dialog(e) else: diff --git a/portato/gui/queue.py b/portato/gui/queue.py index b18e4e7..d3ae1f2 100644 --- a/portato/gui/queue.py +++ b/portato/gui/queue.py @@ -10,7 +10,7 @@ # # Written by René 'Necoro' Neumann <necoro@necoro.net> -from __future__ import absolute_import +from future_builtins import map, filter, zip # some stuff needed import os, pty @@ -61,7 +61,7 @@ class EmergeQueue: # member vars self.tree = tree - if self.tree and not isinstance(self.tree, GtkTree): raise TypeError, "tree passed is not a GtkTree-object" + if self.tree and not isinstance(self.tree, GtkTree): raise TypeError("tree passed is not a GtkTree-object") self.console = console @@ -170,7 +170,7 @@ class EmergeQueue: for i in new_iuse.difference(old_iuse): changedUse.append("+"+i) - except backend.PackageNotFoundException, e: # package not found / package is masked -> delete current tree and re-raise the exception + except backend.PackageNotFoundException as e: # package not found / package is masked -> delete current tree and re-raise the exception if type == "update": # remove complete tree self.remove_with_children(self.tree.first_iter(it), removeNewFlags = False) @@ -321,7 +321,7 @@ class EmergeQueue: def doEmerge (self, options, packages, its, *args, **kwargs): top = None if self.tree and its: - for v in its.itervalues(): + for v in its.values(): self.tree.set_in_progress(v) top = self.tree.first_iter(v) break @@ -361,7 +361,7 @@ class EmergeQueue: os.dup2(self.pty[1], 2) # get all categories that are being touched during the emerge process - cats = set(x.split("/")[0] for x in its.iterkeys()) + cats = set(x.split("/")[0] for x in its.keys()) # start emerge self.process = Popen(command+options+packages, shell = False, env = system.get_environment(), preexec_fn = pre) @@ -642,7 +642,7 @@ class EmergeQueue: elif self.tree.is_in_unmerge(it): # in Unmerge try: del self.iters["uninstall"][cpv] - except KeyError, e: # this is just for debugging + except KeyError as e: # this is just for debugging error("'%s' not in self.iters[\"uninstall\"] for some reason", cpv) debug("self.iters: %s", self.iters) raise @@ -661,4 +661,4 @@ class EmergeQueue: @returns: True if everything is empty and the process is not running. @rtype: bool""" - return not (self.process or any(map(len, self.iters.itervalues()))) + return not (self.process or any(map(len, self.iters.values()))) diff --git a/portato/gui/slots.py b/portato/gui/slots.py index 75f4d77..2706d75 100644 --- a/portato/gui/slots.py +++ b/portato/gui/slots.py @@ -10,7 +10,7 @@ # # Written by René 'Necoro' Neumann <necoro@necoro.net> -from __future__ import absolute_import, with_statement + import gtk from ..plugin import WidgetSlot # other modules might import WidgetSlot from here diff --git a/portato/gui/updater.py b/portato/gui/updater.py index 6539913..397797d 100644 --- a/portato/gui/updater.py +++ b/portato/gui/updater.py @@ -10,7 +10,7 @@ # # Written by René 'Necoro' Neumann <necoro@necoro.net> -from __future__ import absolute_import + from ..backend import system @@ -43,7 +43,7 @@ d""" """ if not issubclass(threadClass, threading.Thread): - raise ValueError, "Only subclasses of threading.Thread are allowed." + raise ValueError("Only subclasses of threading.Thread are allowed.") self.queue = queue self.iterators = iterators diff --git a/portato/gui/utils.py b/portato/gui/utils.py index ce5971e..07db45c 100644 --- a/portato/gui/utils.py +++ b/portato/gui/utils.py @@ -10,8 +10,6 @@ # # Written by René 'Necoro' Neumann <necoro@necoro.net> -from __future__ import absolute_import, with_statement - # some stuff needed import sys import logging @@ -45,7 +43,7 @@ class GtkThread (Thread): try: sys.excepthook(type, val, tb, thread = self.getName()) except TypeError: - raise type, val, tb # let normal thread handle it + raise type(val).with_traceback(tb) # let normal thread handle it finally: del type, val, tb diff --git a/portato/gui/views.py b/portato/gui/views.py index bb96564..5abf081 100644 --- a/portato/gui/views.py +++ b/portato/gui/views.py @@ -10,7 +10,7 @@ # # Written by René 'Necoro' Neumann <necoro@necoro.net> -from __future__ import absolute_import, with_statement + import gtk, gobject import pango @@ -126,7 +126,7 @@ class HighlightView (gtksourceview2.View, LazyView): try: with open(self.get_fn(self.pkg)) as f: return f.readlines() - except IOError, e: + except IOError as e: return _("Error: %s") % e.strerror class LogView (logging.Handler): diff --git a/portato/gui/windows/about.py b/portato/gui/windows/about.py index 0d2ce1a..f59e791 100644 --- a/portato/gui/windows/about.py +++ b/portato/gui/windows/about.py @@ -10,7 +10,7 @@ # # Written by René 'Necoro' Neumann <necoro@necoro.net> -from __future__ import absolute_import, with_statement + import os import gtk diff --git a/portato/gui/windows/basic.py b/portato/gui/windows/basic.py index 01d31e5..3f8c535 100644 --- a/portato/gui/windows/basic.py +++ b/portato/gui/windows/basic.py @@ -10,7 +10,7 @@ # # Written by René 'Necoro' Neumann <necoro@necoro.net> -from __future__ import absolute_import + # gtk stuff import gtk diff --git a/portato/gui/windows/mailinfo.py b/portato/gui/windows/mailinfo.py index 4367482..3cdfb7d 100644 --- a/portato/gui/windows/mailinfo.py +++ b/portato/gui/windows/mailinfo.py @@ -10,7 +10,7 @@ # # Written by René 'Necoro' Neumann <necoro@necoro.net> -from __future__ import absolute_import, with_statement + import smtplib, socket import time @@ -152,7 +152,7 @@ class MailInfoWindow (AbstractDialog): else: debug("TLS not supported in Python. Continuing without it.") server.sendmail(self.addr, self.TO, self.message.as_string()) - except smtplib.SMTPRecipientsRefused, e: + except smtplib.SMTPRecipientsRefused as e: if e.recipients[self.TO][0] < 500: info(_("An error occurred while sending. I think we were greylisted. The error: %s") % e) else: raise @@ -164,11 +164,11 @@ class MailInfoWindow (AbstractDialog): server.quit() except smtplib.SMTPServerDisconnected: pass # ignore this - except socket.error, e: + except socket.error as e: gobject.idle_add(mail_failure_dialog, "%s (Code: %s)" % (e.args[1], e.args[0])) - except smtplib.SMTPResponseException, e: + except smtplib.SMTPResponseException as e: gobject.idle_add(mail_failure_dialog, "%s (Code: %s)" % (e.smtp_error, e.smtp_code)) - except smtplib.SMTPException, e: + except smtplib.SMTPException as e: gobject.idle_add(mail_failure_dialog, e.args) def cb_cancel_clicked (self, *args): diff --git a/portato/gui/windows/main.py b/portato/gui/windows/main.py index de62f45..261b999 100644 --- a/portato/gui/windows/main.py +++ b/portato/gui/windows/main.py @@ -10,7 +10,7 @@ # # Written by René 'Necoro' Neumann <necoro@necoro.net> -from __future__ import absolute_import, with_statement +from future_builtins import map, filter, zip # gtk stuff import gtk @@ -199,15 +199,15 @@ class PackageTable: try: try: self.queue.append(self.pkg.get_cpv(), type = type, update = update) - except PackageNotFoundException, e: + except PackageNotFoundException as e: if dialogs.unmask_dialog(e[0]) == gtk.RESPONSE_YES: self.queue.append(self.pkg.get_cpv(), type = type, unmask = True, update = update) - except BlockedException, e: + except BlockedException as e: dialogs.blocked_dialog(e[0], e[1]) else: try: self.queue.append(self.pkg.get_cpv(), type = "uninstall") - except PackageNotFoundException, e: + except PackageNotFoundException as e: error(_("Package could not be found: %s"), e[0]) #masked_dialog(e[0]) @@ -464,7 +464,7 @@ class MainWindow (Window): splash(_("Loading Config")) try: self.cfg = Config(CONFIG_LOCATION) - except IOError, e: + except IOError as e: dialogs.io_ex_dialog(e) raise @@ -521,7 +521,7 @@ class MainWindow (Window): # notebooks self.sysNotebook = self.tree.get_widget("systemNotebook") self.pkgNotebook = self.tree.get_widget("packageNotebook") - self.set_notebook_tabpos(map(PreferenceWindow.tabpos.get, map(int, (self.cfg.get("packageTabPos", "GUI"), self.cfg.get("systemTabPos", "GUI"))))) + self.set_notebook_tabpos(list(map(PreferenceWindow.tabpos.get, list(map(int, (self.cfg.get("packageTabPos", "GUI"), self.cfg.get("systemTabPos", "GUI"))))))) slots.NotebookSlot(self.pkgNotebook, gtk.Widget, "Package Notebook") # the useScroll @@ -555,9 +555,9 @@ class MainWindow (Window): try: try: self.load_session() - except OldSessionException, e: + except OldSessionException as e: self.load_session(e) - except SessionException, e: + except SessionException as e: warning(str(e)) self.load_session(defaults_only = True) # last ressort @@ -782,7 +782,7 @@ class MainWindow (Window): # to not query the package with info, we do not need if self.cfg.get_boolean("showSlots", "GUI"): def get_slot(pkg): - return pkg.get_package_settings("SLOT") + return pkg.get_slot() self.slotcol.set_visible(True) @@ -891,7 +891,7 @@ class MainWindow (Window): def build_type_combo (self): model = gtk.ListStore(int, str) - for k,v in self.db.TYPES.iteritems(): + for k,v in self.db.TYPES.items(): model.append((k,v)) self.typeCombo.set_model(model) @@ -915,7 +915,7 @@ class MainWindow (Window): """ try: self.session = Session("gui.cfg", name="GUI", oldfiles=["gtk_session.cfg"]) - except (OSError, IOError), e: + except (OSError, IOError) as e: dialogs.io_ex_dialog(e) return @@ -953,7 +953,7 @@ class MainWindow (Window): # PANED def load_paned (*pos): - pos = map(int, pos) + pos = list(map(int, pos)) [x.set_position(p) for x,p in zip((self.vpaned, self.hpaned), pos)] def save_paned (): @@ -1056,7 +1056,7 @@ class MainWindow (Window): self.session.add_handler(value) # set the simple ones :) - map(_add,[ + list(map(_add,[ ([("gtksessionversion", "session")], load_session_version, lambda: SESSION_VERSION), (["width", "height"], lambda w,h: self.window.resize(int(w), int(h)), self.window.get_size), (["vpanedpos", "hpanedpos"], load_paned, save_paned), @@ -1064,7 +1064,7 @@ class MainWindow (Window): (["pkgsel"], load_pkg_selection, save_pkg_selection, ["portato@0"]), (["searchtype"], load_search_type, lambda: self.db.type) #([("merge", "queue"), ("unmerge", "queue"), ("oneshot", "queue")], load_queue, save_queue), - ]) + ])) # set the plugins queue = plugin.get_plugin_queue() @@ -1073,7 +1073,8 @@ class MainWindow (Window): self.session.add_handler(([(p.name.replace(" ","_").replace(":","_"), "plugins")], load_plugin(p), save_plugin(p))) # the other things - def load_cfg ((name, cat)): + def load_cfg (pkg): + (name, cat) = pkg def load (v): self.cfg.set_session(name, cat, v) @@ -1086,7 +1087,7 @@ class MainWindow (Window): self.session.add_handler(([(name, cat)], load, save)) - map(load_cfg, [("prefheight", "GUI"), ("prefwidth", "GUI")]) + list(map(load_cfg, [("prefheight", "GUI"), ("prefwidth", "GUI")])) # now we have the handlers -> load self.session.load(defaults_only) @@ -1307,7 +1308,7 @@ class MainWindow (Window): self.selCP = "%s/%s" % (store.get_value(it, 2), store.get_value(it, 1)) try: self.fill_version_list(self.selCP) - except VersionsNotFoundException, e: + except VersionsNotFoundException as e: warning(_("No versions of package '%s' found!") % self.selCP) dialogs.no_versions_dialog(self.selCP) self.db.disable(self.selCP) @@ -1447,7 +1448,7 @@ class MainWindow (Window): self.session.set("useflags", str(dialogs.changed_flags_dialog(_("use flags"))[1]), "dialogs") try: flags.write_use_flags() - except IOError, e: + except IOError as e: dialogs.io_ex_dialog(e) return True @@ -1460,7 +1461,7 @@ class MainWindow (Window): try: flags.write_masked() flags.write_testing() - except IOError, e: + except IOError as e: dialogs.io_ex_dialog(e) return True else: @@ -1494,12 +1495,12 @@ class MainWindow (Window): try: for pkg, old_pkg in updating: self.queue.append(pkg.get_cpv(), type = "update", unmask = False) - except PackageNotFoundException, e: + except PackageNotFoundException as e: if dialogs.unmask_dialog(e[0]) == gtk.RESPONSE_YES: for pkg, old_pkg in updating: self.queue.append(pkg.get_cpv(), type = "update", unmask = True) - except BlockedException, e: + except BlockedException as e: dialogs.blocked_dialog(e[0], e[1]) self.queue.remove_children(self.queueTree.get_update_it()) @@ -1576,7 +1577,7 @@ class MainWindow (Window): flags.write_use_flags() flags.write_testing() flags.write_masked() - except IOError, e: + except IOError as e: dialogs.io_ex_dialog(e) @Window.watch_cursor diff --git a/portato/gui/windows/pkglist.py b/portato/gui/windows/pkglist.py index df3ef46..956d929 100644 --- a/portato/gui/windows/pkglist.py +++ b/portato/gui/windows/pkglist.py @@ -10,7 +10,7 @@ # # Written by René 'Necoro' Neumann <necoro@necoro.net> -from __future__ import absolute_import + import gtk from .basic import AbstractDialog @@ -107,11 +107,11 @@ class PkgListWindow (AbstractDialog): try: try: self.queue.append(item, "install", oneshot = True) - except PackageNotFoundException, e: + except PackageNotFoundException as e: if unmask_dialog(e[0]) == gtk.RESPONSE_YES : self.queue.append(item, "install", unmask = True, oneshot = True) - except BlockedException, e: + except BlockedException as e: blocked_dialog(e[0], e[1]) else: for item in items: diff --git a/portato/gui/windows/plugin.py b/portato/gui/windows/plugin.py index 89d38f5..14d38b1 100644 --- a/portato/gui/windows/plugin.py +++ b/portato/gui/windows/plugin.py @@ -10,7 +10,7 @@ # # Written by René 'Necoro' Neumann <necoro@necoro.net> -from __future__ import absolute_import +from future_builtins import map, filter, zip import gtk @@ -40,8 +40,8 @@ class PluginWindow (AbstractDialog): self.inst = [] self.ninst = [] - self.buttons = map(self.tree.get_widget, ("disabledRB", "tempEnabledRB", "enabledRB", "tempDisabledRB")) - map(lambda b: b.set_mode(False), self.buttons) + self.buttons = list(map(self.tree.get_widget, ("disabledRB", "tempEnabledRB", "enabledRB", "tempDisabledRB"))) + list(map(lambda b: b.set_mode(False), self.buttons)) self.descrLabel = self.tree.get_widget("descrLabel") self.authorLabel = self.tree.get_widget("authorLabel") @@ -108,7 +108,7 @@ class PluginWindow (AbstractDialog): debug("new changed plugins: %s => %d", plugin.name, state) def cb_ok_clicked (self, btn): - for plugin, val in self.changedPlugins.iteritems(): + for plugin, val in self.changedPlugins.items(): plugin.status = val self.close() @@ -164,10 +164,10 @@ class PluginWindow (AbstractDialog): try: try: self.queue.append(pkg, type = "install") - except PackageNotFoundException, e: + except PackageNotFoundException as e: if unmask_dialog(e[0]) == gtk.RESPONSE_YES: self.queue.append(pkg, type = "install", unmask = True) - except BlockedException, e: + except BlockedException as e: blocked_dialog(e[0], e[1]) return True diff --git a/portato/gui/windows/preference.py b/portato/gui/windows/preference.py index 2b6974e..772c0c7 100644 --- a/portato/gui/windows/preference.py +++ b/portato/gui/windows/preference.py @@ -10,7 +10,7 @@ # # Written by René 'Necoro' Neumann <necoro@necoro.net> -from __future__ import absolute_import +from future_builtins import map, filter, zip import gtk @@ -111,14 +111,14 @@ class PreferenceWindow (AbstractDialog): hintEB.modify_bg(gtk.STATE_NORMAL, get_color(self.cfg, "prefhint")) # the checkboxes - for box, val in self.checkboxes.iteritems(): + for box, val in self.checkboxes.items(): if isinstance(val, tuple): self.tree.get_widget(box).set_active(self.cfg.get_boolean(val[0], section = val[1])) else: self.tree.get_widget(box).set_active(self.cfg.get_boolean(val)) # the edits - for edit, val in self.edits.iteritems(): + for edit, val in self.edits.items(): if isinstance(val,tuple): self.tree.get_widget(edit).set_text(self.cfg.get(val[0], section = val[1])) else: @@ -191,13 +191,13 @@ class PreferenceWindow (AbstractDialog): def _save(self): """Sets all options in the Config-instance.""" - for box, val in self.checkboxes.iteritems(): + for box, val in self.checkboxes.items(): if isinstance(val, tuple): self.cfg.set(val[0], self.tree.get_widget(box).get_active(), section = val[1]) else: self.cfg.set(val, self.tree.get_widget(box).get_active()) - for edit, val in self.edits.iteritems(): + for edit, val in self.edits.items(): if isinstance(val,tuple): self.cfg.set(val[0], self.tree.get_widget(edit).get_text(), section = val[1]) else: @@ -218,7 +218,7 @@ class PreferenceWindow (AbstractDialog): self.cfg.set("packageTabPos", str(pkgPos), section = "GUI") self.cfg.set("systemTabPos", str(sysPos), section = "GUI") - self.tabpos_fn(map(self.tabpos.get, (pkgPos, sysPos))) + self.tabpos_fn(list(map(self.tabpos.get, (pkgPos, sysPos)))) self.linkbtn_fn(self.cfg.get("browserCmd", section="GUI")) @@ -272,7 +272,7 @@ class PreferenceWindow (AbstractDialog): self._save() try: self.cfg.write() - except IOError, e: + except IOError as e: io_ex_dialog(e) self.window.destroy() diff --git a/portato/gui/windows/search.py b/portato/gui/windows/search.py index f9191d7..9485396 100644 --- a/portato/gui/windows/search.py +++ b/portato/gui/windows/search.py @@ -10,7 +10,7 @@ # # Written by René 'Necoro' Neumann <necoro@necoro.net> -from __future__ import absolute_import + import gtk from .basic import AbstractDialog diff --git a/portato/gui/windows/splash.py b/portato/gui/windows/splash.py index 2e9d5a8..bd46f62 100644 --- a/portato/gui/windows/splash.py +++ b/portato/gui/windows/splash.py @@ -10,7 +10,7 @@ # # Written by René 'Necoro' Neumann <necoro@necoro.net> -from __future__ import absolute_import + import gtk |