summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--portato/gui/exception_handling.py24
-rw-r--r--portato/gui/utils.py23
-rw-r--r--portato/gui/windows/mailinfo.py2
-rw-r--r--portato/gui/windows/main.py3
-rw-r--r--portato/plugins/new_version.py2
5 files changed, 25 insertions, 29 deletions
diff --git a/portato/gui/exception_handling.py b/portato/gui/exception_handling.py
index 9a593c1..eadf124 100644
--- a/portato/gui/exception_handling.py
+++ b/portato/gui/exception_handling.py
@@ -16,34 +16,12 @@ from __future__ import absolute_import, with_statement
import gtk, pango, gobject
import sys, traceback
-from threading import Thread
from StringIO import StringIO
from ..helper import debug, error
from .dialogs import file_chooser_dialog, io_ex_dialog
-
-# for the i18n
-from ..constants import LOCALE_DIR, APP
-import gettext
-
-class GtkThread (Thread):
- def run(self):
- # for some reason, I have to install this for each thread ...
- gettext.install(APP, LOCALE_DIR, unicode = True)
- try:
- Thread.run(self)
- except SystemExit:
- raise # let normal thread handle it
- except:
- type, val, tb = sys.exc_info()
- try:
- sys.excepthook(type, val, tb, thread = self.getName())
- except TypeError:
- raise type, val, tb # let normal thread handle it
- finally:
- del type, val, tb
-
from .windows.mailinfo import MailInfoWindow
+from .utils import GtkThread
class UncaughtExceptionDialog(gtk.MessageDialog):
"""Original idea by Gustavo Carneiro - original code: http://www.daa.com.au/pipermail/pygtk/attachments/20030828/2d304204/gtkexcepthook.py."""
diff --git a/portato/gui/utils.py b/portato/gui/utils.py
index 0a2930b..6e04814 100644
--- a/portato/gui/utils.py
+++ b/portato/gui/utils.py
@@ -14,19 +14,38 @@ from __future__ import absolute_import, with_statement
# some stuff needed
import re
+import sys
import logging
+import gettext
from collections import defaultdict
-from threading import RLock
+from threading import Thread, RLock
from functools import wraps
# some backend things
from ..backend import flags, system, set_system
from ..helper import debug, info, set_log_level
-from ..constants import USE_CATAPULT
+from ..constants import USE_CATAPULT, APP, LOCALE_DIR
# parser
from ..config_parser import ConfigParser
+class GtkThread (Thread):
+ def run(self):
+ # for some reason, I have to install this for each thread ...
+ gettext.install(APP, LOCALE_DIR, unicode = True)
+ try:
+ Thread.run(self)
+ except SystemExit:
+ raise # let normal thread handle it
+ except:
+ type, val, tb = sys.exc_info()
+ try:
+ sys.excepthook(type, val, tb, thread = self.getName())
+ except TypeError:
+ raise type, val, tb # let normal thread handle it
+ finally:
+ del type, val, tb
+
class Config (ConfigParser):
def __init__ (self, cfgFile):
diff --git a/portato/gui/windows/mailinfo.py b/portato/gui/windows/mailinfo.py
index ebecf35..93d2be4 100644
--- a/portato/gui/windows/mailinfo.py
+++ b/portato/gui/windows/mailinfo.py
@@ -17,7 +17,7 @@ import smtplib
import time
from .basic import AbstractDialog
-from ..exception_handling import GtkThread
+from ..utils import GtkThread
from ...helper import debug
from ...constants import VERSION
diff --git a/portato/gui/windows/main.py b/portato/gui/windows/main.py
index b675d17..8e5eafb 100644
--- a/portato/gui/windows/main.py
+++ b/portato/gui/windows/main.py
@@ -30,11 +30,10 @@ from ...constants import CONFIG_LOCATION, VERSION, APP_ICON, ICON_DIR
from ...backend.exceptions import PackageNotFoundException, BlockedException
# more GUI stuff
-from ..utils import Database, Config
+from ..utils import Database, Config, GtkThread
from ..queue import EmergeQueue
from ..session import SESSION_VERSION, SessionException, OldSessionException, NewSessionException
from ..wrapper import GtkTree, GtkConsole
-from ..exception_handling import GtkThread
from ..views import LogView, HighlightView, InstalledOnlyView
from ..dialogs import (blocked_dialog, changed_flags_dialog, io_ex_dialog,
nothing_found_dialog, queue_not_empty_dialog, remove_deps_dialog,
diff --git a/portato/plugins/new_version.py b/portato/plugins/new_version.py
index 462d67c..fe69292 100644
--- a/portato/plugins/new_version.py
+++ b/portato/plugins/new_version.py
@@ -7,7 +7,7 @@ import gobject
from portato.helper import debug, warning
from portato import get_listener
from portato.constants import VERSION, APP_ICON, APP
-from portato.gui.exception_handling import GtkThread
+from portato.gui.utils import GtkThread
def find_version (rev):
try: