Closed Bug 854611 Opened 11 years ago Closed 11 years ago

add notifications to mach build

Categories

(Firefox Build System :: General, defect)

x86_64
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla26

People

(Reporter: mmc, Assigned: gps)

References

Details

(Whiteboard: [mach])

Attachments

(1 file)

I wrapped my own build invocation to 

#!/bin/bash
msg="Please try again"
./mach -l build.log. build
if [ $? -eq 0 ]; then
  msg="Success!"
fi
notify-send "Your build is done!" "$msg" --icon=dialog-information

On OS X 'say "build complete"' does similar

This is a great productivity improvement for medium and long builds, where it doesn't make sense to wait on the build, but many compile-debug cycles are needed.
Adding notifications to completion of long-running commands has been on the long, undocumented TODO list. Thanks for filing this!

I'd be in favor of adding this as a core mach feature - one that commands don't have to opt into.

So, how do we go about alerting on different platforms?

I believe the OS X built-in terminal will bounce if it receives the bell character. That's easy! But, a lot of people use iTerm, which doesn't handle bells that way. Hmm. https://github.com/alloy/terminal-notifier seems to be the most popular CLI tool for sending messages to the system notification center in OS X 10.8. Although, we could defer that to a follow-up.

Is notify-send common on Linux distros or is it an Ubuntu thing?

I'm not sure what we can do on Windows. Is there a sequence you can emit to turn your preview window in the task bar a different color or something?

I imagine this feature devolves into heuristics to detect what notification methods are available and selecting the "best" one. Perhaps we can start with bell character and/or notify-send?
(In reply to Gregory Szorc [:gps] from comment #1)
> Adding notifications to completion of long-running commands has been on the
> long, undocumented TODO list. Thanks for filing this!

Awesome :)

> Is notify-send common on Linux distros or is it an Ubuntu thing?

I wish I knew -- I think it's any linux that supports libnotify but I can't tell from this page which ones there are:

https://www.archlinux.org/packages/?name=libnotify

The nice thing is that it supports python bindings which may help with portability.

> I'm not sure what we can do on Windows. Is there a sequence you can emit to
> turn your preview window in the task bar a different color or something?
> 
> I imagine this feature devolves into heuristics to detect what notification
> methods are available and selecting the "best" one. Perhaps we can start
> with bell character and/or notify-send?

terminal-bell seems like it works most anywhere. growl seems like it's pretty well supported for both MacOS and windows:

http://lifehacker.com/5350422/battle-of-the-windows-notification-apps-growl-for-windows-vs-snarl
I saw Monica at lunch today and it reminded me of this open bug. I
figured it would be an easy patch to take my mind off reviews.

This patch is a far-from-robust implementation of notifications. It only
works on OS X with Notification Center (10.8+). It only notifies for long
builds, not other mach commands. These can be addressed over time if
this feature is well-received. As the in-line comment states, I'm mostly
interested in testing the waters to see what the reaction is before
rolling this out more widely.
Attachment #781989 - Flags: review?(ted)
Assignee: nobody → gps
Component: mach → Build Config
Summary: add notifications to ./mach → add notifications to mach build
Whiteboard: [mach]
Please factor it out a little, I want to add libnotify support :)
Comment on attachment 781989 [details] [diff] [review]
Notification Center notification when a long build completes

Review of attachment 781989 [details] [diff] [review]:
-----------------------------------------------------------------

::: python/mozbuild/mozbuild/mach_commands.py
@@ +347,5 @@
>          high_finder, finder_percent = monitor.have_high_finder_usage()
>          if high_finder:
>              print(FINDER_SLOW_MESSAGE % finder_percent)
>  
> +        if monitor.elasped > 300:

Seems funny to have two different "long build" interpretations.

@@ +355,5 @@
> +            # is received.
> +            try:
> +                if sys.platform.startswith('darwin'):
> +                    notifier = which.which('terminal-notifier')
> +                    self.run_process([notifier, '-title',

It'd probably be a little nicer to check that you actually found terminal-notifier instead of blindly executing it and swallowing the exception.
Attachment #781989 - Flags: review?(ted) → review+
(In reply to Gregory Szorc [:gps] from comment #3)
> Created attachment 781989 [details] [diff] [review]
> Notification Center notification when a long build completes
> 
> I saw Monica at lunch today and it reminded me of this open bug. I
> figured it would be an easy patch to take my mind off reviews.

So, is it time to have lunch again? ;)
Somehow I committed a typo.

https://hg.mozilla.org/integration/mozilla-inbound/rev/b8635842cc9f
Status: NEW → ASSIGNED
https://hg.mozilla.org/mozilla-central/rev/20c45ad8733b
https://hg.mozilla.org/mozilla-central/rev/b8635842cc9f
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla26
Depends on: 913276
I just upgraded to 10.9 and this suddenly started to work for me!  This is *so* amazing!
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: