Bug 1048799 - Improve mach build notification center errors. r=gps

This commit is contained in:
Mike Hommey 2014-08-07 02:58:46 +09:00
parent f9a1f7967a
commit 1aa0b26726

View File

@ -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}')