Skip to content

Commit

Permalink
Fixed and3rson#37: Prevent crash importing dbus without a notificatio…
Browse files Browse the repository at this point in the history
…n target
  • Loading branch information
agg23 committed Sep 18, 2018
1 parent c271cec commit ec7e9dd
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions clay/osd.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from clay.notifications import notification_area
from clay import meta
from clay.log import logger

IS_INIT = False

Expand All @@ -17,8 +18,7 @@
ERROR_MESSAGE = 'Error while importing dbus: \'{}\''.format(str(exception))

if not IS_INIT:
notification_area.notify(ERROR_MESSAGE)

logger.error(ERROR_MESSAGE)

class _OSDManager(object):
"""
Expand All @@ -29,11 +29,14 @@ def __init__(self):

if IS_INIT:
self.bus = SessionBus()
self.notifcations = self.bus.get_object(
"org.freedesktop.Notifications",
"/org/freedesktop/Notifications"
)
self.notify_interface = Interface(self.notifcations, "org.freedesktop.Notifications")
try:
self.notifcations = self.bus.get_object(
"org.freedesktop.Notifications",
"/org/freedesktop/Notifications"
)
self.notify_interface = Interface(self.notifcations, "org.freedesktop.Notifications")
except Exception as exception: # pylint: disable=broad-except
logger.error('Error while importing dbus: \'%s\'', str(exception))

def notify(self, track):
"""
Expand Down

0 comments on commit ec7e9dd

Please sign in to comment.