From 1aa0b2672691374d227930a9e5228c6ef08ad5e1 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Thu, 7 Aug 2014 02:58:46 +0900 Subject: [PATCH] Bug 1048799 - Improve mach build notification center errors. r=gps --- python/mozbuild/mozbuild/mach_commands.py | 25 +++++++++++++---------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/python/mozbuild/mozbuild/mach_commands.py b/python/mozbuild/mozbuild/mach_commands.py index 25caa6f83a8..4fe841c1082 100644 --- a/python/mozbuild/mozbuild/mach_commands.py +++ b/python/mozbuild/mozbuild/mach_commands.py @@ -407,24 +407,27 @@ class Build(MachCommandBase): # is received. try: if sys.platform.startswith('darwin'): - notifier = which.which('terminal-notifier') + try: + notifier = which.which('terminal-notifier') + except which.WhichError: + raise Exception('Install terminal-notifier to get ' + 'a notification when the build finishes.') self.run_process([notifier, '-title', 'Mozilla Build System', '-group', 'mozbuild', '-message', 'Build complete'], ensure_exit_code=False) elif sys.platform.startswith('linux'): try: import dbus - bus = dbus.SessionBus() - notify = bus.get_object('org.freedesktop.Notifications', - '/org/freedesktop/Notifications') - method = notify.get_dbus_method('Notify', - 'org.freedesktop.Notifications') - method('Mozilla Build System', 0, '', 'Build complete', '', [], [], -1) - except (ImportError, dbus.exceptions.DBusException): - pass + except ImportError: + raise Exception('Install the python dbus module to ' + 'get a notification when the build finishes.') + bus = dbus.SessionBus() + notify = bus.get_object('org.freedesktop.Notifications', + '/org/freedesktop/Notifications') + method = notify.get_dbus_method('Notify', + 'org.freedesktop.Notifications') + method('Mozilla Build System', 0, '', 'Build complete', '', [], [], -1) - except (which.WhichError, ImportError): - pass except Exception as e: self.log(logging.WARNING, 'notifier-failed', {'error': e.message}, 'Notification center failed: {error}')