Skip to content

Commit

Permalink
Ignore DBuxException when sending a notification
Browse files Browse the repository at this point in the history
Because sending notifications is not the main feature, backintime should
continue to work when that fails.

Idea from #1156 (comment)
  • Loading branch information
Zocker1999NET committed Sep 25, 2022
1 parent fad3baf commit b299a72
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions qt/plugins/notifyplugin.py
Expand Up @@ -54,7 +54,10 @@ def isGui(self):
return True

def message(self, profile_id, profile_name, level, message, timeout):
notify_interface = dbus.Interface(object=dbus.SessionBus().get_object("org.freedesktop.Notifications", "/org/freedesktop/Notifications"), dbus_interface="org.freedesktop.Notifications")
try:
notify_interface = dbus.Interface(object=dbus.SessionBus().get_object("org.freedesktop.Notifications", "/org/freedesktop/Notifications"), dbus_interface="org.freedesktop.Notifications")
except dbus.exceptions.DBusException:
return
if 1 == level:
if timeout > 0:
timeout = 1000 * timeout
Expand All @@ -63,5 +66,8 @@ def message(self, profile_id, profile_name, level, message, timeout):
title = "Back In Time (%s) : %s" % (self.user, profile_name)
message = message.replace("\n", ' ')
message = message.replace("\r", '')
notify_interface.Notify("Back In Time", 0, "", title, message, [], {}, timeout)
try:
notify_interface.Notify("Back In Time", 0, "", title, message, [], {}, timeout)
except dbus.exceptions.DBusException:
pass
return

0 comments on commit b299a72

Please sign in to comment.