8

Using Growl in python but having no luck with anything appearing. Using the following code. Running on OSX Lion with Growl 1.3.3. Anyone got this working?

import Growl

notifier = Growl.GrowlNotifier(applicationName='mzgrowl', notifications=['alive'])
notifier.register()
notifier.notify('alive', 'mzgrowl', 'test message')
Maria Zverina
  • 9,753
  • 3
  • 41
  • 60
  • Error message? Stacktrace? Or is it just not working? – BluePeppers May 15 '12 at 21:32
  • Bit more info. I've tried the same code on OSX Lion running Growl 1.2.2 and it works perfectly. But still no luck with Growl 1.3.3. Have the python bindings changed? – Maria Zverina May 16 '12 at 08:38
  • I know that 1.3.3 is no longer open source and is a paid release. 1.2.2 is the latest free version. Does it have anything to do with that? – ThinkCode May 22 '12 at 22:06
  • Command line app growlnotify seems to be able to work with 1.3 ... so hopefully it's something that still can be done. Also 1.3 continues to be available as free (open source) version. You just have to pay for compiling service if you want the convenience. And yes, I am using the paid version from the App Store - might try with the self compile version in a bit. – Maria Zverina May 23 '12 at 17:37
  • @ThinkCode: according to this blog post (http://growl.posterous.com/growl-13-a-summary-of-the-major-changes): "Growl has always been, and will always be, open source " – Bryan Oakley Jun 05 '12 at 14:40

2 Answers2

3

It looks like there is a new python bindings library for growl: gntp

You may have better luck with that.

Matthew Schinckel
  • 32,344
  • 6
  • 71
  • 109
0

Here's another solution that works with Growl 1.2. I don't have 1.3 to test with. It's better than most of the solutions floating around because you don't have to turn on growl networking.

From http://wiki.python.org/moin/MacPython/Growl/AppleScriptSupport:

$ pip install appscript

and run this:

from appscript import *

# connect to Growl
growl = app('GrowlHelperApp')

# Make a list of all the notification types 
# that this script will ever send:
allNotificationsList = ['Test Notification', 'Another Test Notification']

# Make a list of the notifications 
# that will be enabled by default.      
# Those not enabled by default can be enabled later 
# in the 'Applications' tab of the growl prefpane.
enabledNotificationsList = ['Test Notification']

# Register our script with growl.
# You can optionally (as here) set a default icon 
# for this script's notifications.
growl.register(
    as_application='Growl Appscript Sample', 
    all_notifications=allNotificationsList, 
    default_notifications=enabledNotificationsList, 
    icon_of_application='PythonIDE')

# Send a Notification...
growl.notify(
    with_name='Test Notification', 
    title='Test Notification', 
    description='This is a test Appscript notification.', 
    application_name='Growl Appscript Sample')
    # You can optionally add an icon by adding one of these as the last arg:
    # icon_of_application="Script Editor.app")
    # icon_of_file="file:///Users/someone/Growl")
    # image_from_location="file:///Users/someone/pictures/stopWatch.png")

# Another one...
growl.notify(
    with_name='Another Test Notification', 
    title='Another Test Notification :) ', 
    description='Alas - you won\'t see me until you enable me...', 
    application_name='Growl Appscript Sample')
Dan Benamy
  • 769
  • 7
  • 14
  • As of 7/13/14 this doesn't work. Copied and pasted directly into text editor, made sure I had installed appscript, and it always breaks at the 1st line of code (without the import line). In IDLE, got to at "growl = app('GrowlHelperApp') and got: "Traceback (most recent call last): File "", line 1, in growl = appscript.app('GrowlHelperApp') NameError: name 'appscript' is not defined" – Tango Jul 13 '14 at 18:36
  • @Tango And you ran "pip install appscript"? – Dan Benamy Jul 15 '14 at 05:49
  • Yes. I have to honestly say, at this point, since I'm working with several different elements of a program, including dealing with Python and AppleScript, plus communicating with multiple modems and notifications, that, right now, I can't duplicate what I did yesterday and be sure I am doing everything the same - so if I find future issues, I will provide an update, but for now, when I couldn't get it to work, I moved on to another set of tasks and didn't keep info beyond what's above. (In other words, I can't repeat and verify, but if/when I can, I'll comment again.) – Tango Jul 15 '14 at 07:00