def notify(self, result): if self.gn: if result == PASS: self.gn.notify(noteType=PASS, title="%s: Tests Passed" % self.name.upper(), description="All tests passed!", icon=Image.imageFromPath(os.path.join(os.path.dirname(__file__), "images", "pass.png"))) elif result == FAIL: self.gn.notify(noteType=FAIL, title="%s: Tests Failed" % self.name.upper(), description="FAIL!!!", icon=Image.imageFromPath(os.path.join(os.path.dirname(__file__), "images", "fail.png"))) else: self.gn.notify(noteType=PASS, title="%s: Running Tests" % self.name.upper(), description="Running tests...", icon=Image.imageFromPath(os.path.join(os.path.dirname(__file__), "images", "pending.png")))
def notifierFactory(): '''Returns the configured notifier, according to environment.''' gn = GrowlNotifier( applicationName= 'LogNotifier', notifications= notifications, applicationIcon= Image.imageWithIconForCurrentApplication() ) gn.register() return gn
def receivedResult(stream, x): for e in x.elements(): if e.name == 'vCard': for ee in e.elements(): if ee.name == 'PHOTO': for eee in ee.elements(): if eee.name == 'BINVAL': image = Image.imageWithData(base64.b64decode(str(eee))) if x['from'] in avatar_cache and isinstance(avatar_cache[x['from']], Deferred): avatar_cache[x['from']].callback(image) avatar_cache[x['from']] = image
def sendGrowl(notice): def notify(notice, icon=None): notifier.notify('notify', notice.get('title', ''), notice['text'], sticky=notice.get('sticky', False), icon=icon) if 'icon' in notice: client.getPage(notice['icon']) \ .addCallback(lambda x: notify(notice, Image.imageWithData(x))) \ .addErrback(lambda x: notify(notice)) else: notify(notice)
def receivedMessage(stream, x): for e in x.elements(): if e.name == "body" and x.hasAttribute('type') and x['type'] == 'chat': message = str(e) avatar_result = getAvatar(stream, x['from']) if message.strip()[0] == '{': message = simplejson.loads(message) if type(message) is dict and 'icon' in message: getPage(message['icon']).addCallback(lambda x: sendGrowl(message, Image.imageWithData(x))) elif isinstance(avatar_result, Deferred): avatar_result.addCallback(lambda x: sendGrowl(message, x)) else: sendGrowl(message, avatar_result)
def __notify(self, title, message, icon_path=None): ''' Sends a Growl notification with the given parameters. ''' if icon_path is not None: icon = Image.imageFromPath(icon_path) else: icon = None self.notifier.notify( GROWL_NOTIFICATIONS_DEFAULT[0], title, message, icon=icon )
def __init__(self): '''Registers a Growl notifier.''' super(Sneazr, self).__init__() # Store resource path to icons in dict. self.icon_paths = {} for status in ['pass', 'error', 'fail']: self.icon_paths[status] = resource_filename( 'resources', 'logo_%s.png' % status ) app_icon = Image.imageFromPath( resource_filename('resources', 'logo.png') ) self.notifier = GrowlNotifier( applicationName='Sneazr', notifications=GROWL_NOTIFICATIONS_DEFAULT, applicationIcon=app_icon ) self.notifier.register()
from repeattimer import RepeatTimer from pyvoice import GoogleVoice from Growl import GrowlNotifier from Growl import Image as GrowlImage def notify(): unread_messages = gv.get_unread_messages() for msg in unread_messages: growlifier.notify(noteType="update", title="New GV Message!", description=("%s- %s" % (msg.elapsedTimeSincePlaced, msg.phoneNumber))) icon_path = "txt.icon.png" if (__name__ == "__main__"): growl_icon = GrowlImage.imageFromPath(icon_path) growlifier = GrowlNotifier(applicationName="Google Voice", notifications=['update'], applicationIcon=growl_icon) growlifier.register() gv = GoogleVoice("*****@*****.**", "laner8") #check for new messages, and update with new Growl alert every 10 minutes timer = RepeatTimer(interval=600, function=notify) timer.run()
return 1 if 'y combinator' in text: return 1 if 'amazon' in text: return 1 if 'twitter' in text: return 1 if 'android' in text: return 1 if 'chrome' in text: return 1 if 'foursquare' in text: return 1 sticky = True icon = Image.imageFromPath('rss.png') feeds = { "Aaron Swartz": ("http://www.aaronsw.com/weblog/index.xml", None, sticky), "A VC": ("http://feeds.feedburner.com/AVc", None, sticky), "catonmat": ("http://feeds.feedburner.com/catonmat", None, sticky), "Heroku": ("http://feeds.feedburner.com/heroku", None, sticky), "Jason Cohen": ("http://feeds2.feedburner.com/blogspot/smartbear", None, sticky), "John Gruber": ("http://daringfireball.net/feeds/articles", None, sticky), "John Resig": ("http://feeds.feedburner.com/JohnResig", None, sticky), # "Marco": ("http://www.marco.org/rss", None, sticky), # "Patrick": ("http://www.kalzumeus.com/feed/", None, sticky), "Paul Buchheit": ("http://paulbuchheit.blogspot.com/feeds/posts/default", None, sticky), "Paul Graham": ("http://www.aaronsw.com/2002/feeds/pgessays.rss", None, sticky), "Sivers": ("http://sivers.org/en.atom", None, sticky), "Steve Blank": ("http://steveblank.com/feed/", None, sticky),
def notify(header,body): gi = Image.imageFromPath('static/images/arduino_logo.png') gn = GrowlNotifier(applicationName="Notify!",notifications=['alert','notification'],applicationIcon=gi) gn.register() gn.notify(noteType='notification',title=header,description=body,icon=gi)