Skip to content

Commit

Permalink
notify_darwin should trap import errors and provide the useful packag…
Browse files Browse the repository at this point in the history
…e name for the user to install.
  • Loading branch information
mt2d2 committed Jun 28, 2015
1 parent 46709ed commit bb426d3
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions python/servo/build_commands.py
Expand Up @@ -64,21 +64,24 @@ class FLASHWINDOW(Structure):


def notify_darwin(title, text):
import Foundation
import objc
try:
import Foundation
import objc

NSUserNotification = objc.lookUpClass("NSUserNotification")
NSUserNotificationCenter = objc.lookUpClass("NSUserNotificationCenter")
NSUserNotification = objc.lookUpClass("NSUserNotification")
NSUserNotificationCenter = objc.lookUpClass("NSUserNotificationCenter")

note = NSUserNotification.alloc().init()
note.setTitle_(title)
note.setInformativeText_(text)
note = NSUserNotification.alloc().init()
note.setTitle_(title)
note.setInformativeText_(text)

now = Foundation.NSDate.dateWithTimeInterval_sinceDate_(0, Foundation.NSDate.date())
note.setDeliveryDate_(now)
now = Foundation.NSDate.dateWithTimeInterval_sinceDate_(0, Foundation.NSDate.date())
note.setDeliveryDate_(now)

centre = NSUserNotificationCenter.defaultUserNotificationCenter()
centre.scheduleNotification_(note)
centre = NSUserNotificationCenter.defaultUserNotificationCenter()
centre.scheduleNotification_(note)
except ImportError:
raise Exception("Please make sure that the Python pyobjc module is installed!")


def notify_build_done(elapsed):
Expand Down

0 comments on commit bb426d3

Please sign in to comment.