diff options
author | Calum Lind <calumlind+deluge@gmail.com> | 2019-06-12 18:43:23 +0100 |
---|---|---|
committer | Calum Lind <calumlind+deluge@gmail.com> | 2019-06-25 10:44:51 +0100 |
commit | 63a4301a8be8f13c1aa21c1cc7b123ba013b2c3a (patch) | |
tree | d47466de88312aca14628f69b978cdb49604f99a | |
parent | 1b4ac88ce72515bcf36684b942e3998900f13cea (diff) | |
download | deluge-63a4301a8be8f13c1aa21c1cc7b123ba013b2c3a.tar.gz deluge-63a4301a8be8f13c1aa21c1cc7b123ba013b2c3a.tar.bz2 deluge-63a4301a8be8f13c1aa21c1cc7b123ba013b2c3a.zip |
[Notifications] Fix unhandled TypeErrors on Python 3
- Notify requires GLib.Variant for set_hint
- Twisted defer.fail only accepts Exceptions.
Fixes: #3267
-rw-r--r-- | deluge/plugins/Notifications/deluge_notifications/gtkui.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/deluge/plugins/Notifications/deluge_notifications/gtkui.py b/deluge/plugins/Notifications/deluge_notifications/gtkui.py index 816cb36e5..486ee677a 100644 --- a/deluge/plugins/Notifications/deluge_notifications/gtkui.py +++ b/deluge/plugins/Notifications/deluge_notifications/gtkui.py @@ -42,7 +42,7 @@ except ImportError: try: require_version('Notify', '0.7') - from gi.repository import Notify + from gi.repository import Notify, GLib except (ValueError, ImportError): POPUP_AVAILABLE = False else: @@ -174,15 +174,17 @@ class GtkUiNotifications(CustomNotifications): if not self.config['popup_enabled']: return defer.succeed(_('Popup notification is not enabled.')) if not POPUP_AVAILABLE: - return defer.fail(_('libnotify is not installed')) + err_msg = _('libnotify is not installed') + log.warning(err_msg) + return defer.fail(ImportError(err_msg)) if Notify.init('Deluge'): self.note = Notify.Notification.new(title, message, 'deluge-panel') - self.note.set_hint('desktop-entry', 'deluge') + self.note.set_hint('desktop-entry', GLib.Variant.new_string('deluge')) if not self.note.show(): err_msg = _('Failed to popup notification') log.warning(err_msg) - return defer.fail(err_msg) + return defer.fail(Exception(err_msg)) return defer.succeed(_('Notification popup shown')) def __play_sound(self, sound_path=''): @@ -191,7 +193,7 @@ class GtkUiNotifications(CustomNotifications): if not SOUND_AVAILABLE: err_msg = _('pygame is not installed') log.warning(err_msg) - return defer.fail(err_msg) + return defer.fail(ImportError(err_msg)) pygame.init() try: @@ -203,7 +205,7 @@ class GtkUiNotifications(CustomNotifications): except pygame.error as ex: err_msg = _('Sound notification failed %s') % ex log.warning(err_msg) - return defer.fail(err_msg) + return defer.fail(ex) else: msg = _('Sound notification Success') log.info(msg) |