Giter VIP home page Giter VIP logo

gntp's Introduction

GNTP

This is a Python library for working with the Growl Notification Transport Protocol

It should work as a dropin replacement for the older Python bindings

Installation

You can install with pip

$ pip install gntp

then test the module

$ python -m gntp.notifier

Simple Usage

# GNTP uses the standard Python logging
import logging
logging.basicConfig(level=logging.INFO)

import gntp.notifier

# Simple "fire and forget" notification
gntp.notifier.mini("Here's a quick message")

# More complete example
growl = gntp.notifier.GrowlNotifier(
    applicationName = "My Application Name",
    notifications = ["New Updates","New Messages"],
    defaultNotifications = ["New Messages"],
    # hostname = "computer.example.com", # Defaults to localhost
    # password = "abc123" # Defaults to a blank password
)
growl.register()

# Send one message
growl.notify(
    noteType = "New Messages",
    title = "You have a new message",
    description = "A longer message description",
    icon = "http://example.com/icon.png",
    sticky = False,
    priority = 1,
)

# Try to send a different type of message
# This one may fail since it is not in our list
# of defaultNotifications
growl.notify(
    noteType = "New Updates",
    title = "There is a new update to download",
    description = "A longer message description",
    icon = "http://example.com/icon.png",
    sticky = False,
    priority = -1,
)

URL based images do not work in the OSX version of growl 1.4 You can send the image along with the notification to get around this.

image = open('/path/to/image.png', 'rb').read()
growl.notify(
    noteType = "New Messages",
    title = "You have a new message",
    description = "This time we embed the image",
    icon = image,
)

Note

With Growl 2 and above user can choose to pass notification to system wide notifications center. In this case icon argument would be ignored by the notification center (there would always be Growl icon instead).

Bugs

GitHub issue tracker

Changelog

v1.0.3
  • Allow file:// scheme to be used for icons
v1.0.2
  • Fix bug with incoming password hash
  • Added info about license in each source file
v1.0.1
  • Fix bug with binary data (images) being encoded incorrectly
v1.0
  • Python 3.3 Support
v0.9
  • Remove duplicate code from gntp.config
  • Catch all errors and rethrow them as gntp.errors to make it easier for other programs to deal with errors from the gntp library.
  • Ensure that we open resource files as "rb" and update the documentation
v0.8
  • Fix a bug where resource sections were missing a CRLF
  • Fix a bug where the cli client was using config values over options
  • Add support for coalescing
v0.7
  • Support for images
  • Better test coverage support
0.6
  • ConfigParser aware GrowlNotifier that reads settings from ~/.gntp

gntp's People

Contributors

goerz avatar hhatto avatar jonschoning avatar jwm avatar kfdm avatar lukaszb avatar snicker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gntp's Issues

Hum...

Hi,

How does it work? I use Eclipse and "import gntp" works. I look at the .doc file Application Integration Guide but the code is C++ inside. How do you register and send event to Growl. Any How To guide about this on the web?

Sorry about creating an issue for beginners questions... :(

Create a pythonic 'sexy' wrapper

Have a GTNP ready with "normal" Growl wrapper that can be used for other projects with a simple structure which won't assume anything (i.e. don't force a user to specify everything)

simple one liner example error

Hi,

I tried to run the one liner on my osx 10.6 (with python 2.7) but keep getting a socket timeout problem.

Is this a compatibility issue or am I missing a setting? I have pasted my modified one liner below:
Simple "fire and forget" notification
gntp.notifier.mini("Here's a quick message",port=23052)

As you can see I had to change the port number from 23053 and I was wondering if there are other settings I need to change.

Error stack says:
"s.connect((self.hostname, self.port))
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
socket.gaierror: [Errno 8] nodename nor servname provided, or not known"

Appreciate your help

Timeout while loading icon

Test script:

# -*- coding: utf-8 -*-
from subprocess import check_output

# GNTP uses the standard Python logging
import logging
logging.basicConfig(level=logging.INFO)

import gntp.notifier

# More complete example
growl = gntp.notifier.GrowlNotifier(
    applicationName = "My Application Name",
    notifications = ["New Updates","New Messages"],
    defaultNotifications = ["New Messages"],
    # hostname = "computer.example.com", # Defaults to localhost
    # password = "abc123" # Defaults to a blank password
)
growl.register()


a = str(check_output(["mpc","-f","%file%"]))
aa = a.split("\n",1)[0].split("/")
l=len(aa[:-1])
aaa = ""
for i in range(0, l):
    aaa = aaa + aa[i] + "/"
folderpath = "/Volumes/My Passport/µziq/" + aaa + "folder.jpg"
# For example: folderpath = "/Volumes/My Passport/µziq/Can - Tago Mago (40th Anniversary Edition) [V0] {Waffles}/Disc 1/folder.jpg"
image = open(folderpath, 'rb').read()

# Send one message
growl.notify(
    noteType = "New Messages",
    title = "You have a new message",
    description = "A longer message description",
    icon = image,
    sticky = False,
    priority = 1,
)

I get error:

INFO:gntp.notifier:Sending registration to localhost:23053
INFO:gntp.notifier:Sending notification [New Messages] to localhost:23053
INFO:gntp.notifier:Checking icon
Traceback (most recent call last):
  File "pytest.py", line 37, in <module>
    priority = 1,
  File "/Library/Python/2.7/site-packages/gntp/notifier.py", line 149, in notify
    return self._send('notify', notice)
  File "/Library/Python/2.7/site-packages/gntp/notifier.py", line 201, in _send
    raise errors.NetworkError(exc)
gntp.errors.NetworkError: timed out

Exception when growl is not installed

In reading the docs for Growl, I believe it should be possible to import the gntp module and dispatch a notification. If I read the docs correctly, 'Mist' should be invoked to display the notification when Growl is not installed.

After installing gntp on a machine without Growl, I do the following in Python 2.7 (OS X 10.8.1):

import gntp.notifier
gntp.notifier.mini("Here's a quick message")

and I get the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/gntp/notifier.py", line 48, in mini
    result = growl.register()
  File "/Library/Python/2.7/site-packages/gntp/notifier.py", line 128, in register
    return self._send('register', register)
  File "/Library/Python/2.7/site-packages/gntp/notifier.py", line 221, in _send
    s.connect((self.hostname, self.port))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 61] Connection refused

Am I misunderstanding the Mist feature?

Notifying to Growl for Linux fails

First few messages are Ok, but after some moment all notifications fail. I'm using gntp 0.9 from pypi and Growl for Linux package from ArchLinux (growl-for-linux-git in aur). Traceback follows.

Traceback (most recent call last):
File "/usr/local/bin/cidd/notifiers/ntfr_task.py", line 70, in run
self._ntfr.notify(ev_num, subj, body)
File "/usr/local/bin/cidd/notifiers/growl_ntfr.py", line 47, in notify
self._notify(ev_num, subj, body, False)
File "/usr/local/bin/cidd/notifiers/growl_ntfr.py", line 29, in notify
sticky=(not fast), identifier='%s
%d' % (self.name, ev_num))
File "/usr/local/lib/python2.6/dist-packages/gntp-0.9-py2.6.egg/gntp/notifier.py", line 142, in notify
return self._send('notify', notice)
File "/usr/local/lib/python2.6/dist-packages/gntp-0.9-py2.6.egg/gntp/notifier.py", line 194, in _send
response = gntp.parse_gntp(recv_data)
File "/usr/local/lib/python2.6/dist-packages/gntp-0.9-py2.6.egg/gntp/init.py", line 487, in parse_gntp
return GNTPError(data)
File "/usr/local/lib/python2.6/dist-packages/gntp-0.9-py2.6.egg/gntp/init.py", line 458, in init
self.decode(data)
File "/usr/local/lib/python2.6/dist-packages/gntp-0.9-py2.6.egg/gntp/init.py", line 225, in decode
self.info = self._parse_info(data)
File "/usr/local/lib/python2.6/dist-packages/gntp-0.9-py2.6.egg/gntp/init.py", line 63, in _parse_info
raise errors.ParseError('ERROR_PARSING_INFO_LINE')
ParseError: ERROR_PARSING_INFO_LINE

The message Prowl received just show one line and the newline part is gone

I installed the regrowl version by snicker. Don’t know if it’s the problem of gntp or the problem of regrowl. The information received by Prowl can only display one line, and the line break part is gone. The newline part has been removed in the Notification-Text of debug info and only the rest was forwarded to Prowl. It is suspected that gntp has a problem with the processing of line breaks after receiving the information.

Icons on local filesystem

Local icon files fail with the current version.

The _checkIcon(self, data) function in notifier.py should be updated to support 'file' URL schemes.

Line 72 should be changed from:
return gntp.shim.u(data).startswith('http')
to:
return gntp.shim.u(data).startswith('http') or gntp.shim.u(data).startswith('file')

ERROR:gntp.notifier:Invalid response

When I try to run the /test/attributes.py script, it fails:

No handlers could be found for logger "gntp.notifier"

When I add the lines to import logging,

import logging
logging.basicConfig(level=logging.ERROR)

I get two errors:

ERROR:gntp.notifier:Invalid response: (u'402', u'A is not registered for Python GNTP')
ERROR:gntp.notifier:Invalid response: (u'402', u'B is not registered for Python GNTP')

EDIT: with debug logging, this is the output:

INFO:gntp.notifier:Sending notification [A] to localhost:23053
DEBUG:gntp.notifier:To : localhost:23053 <<class 'gntp.core.GNTPNotice'>>
GNTP/1.0 NOTIFY NONE
Application-Name: Python GNTP
Notification-Sticky: True
Notification-Name: A
Notification-Text: A
Origin-Platform-Version: Darwin-12.4.0-x86_64-i386-64bit
Origin-Software-Version: 1.0.1
Origin-Machine-Name: mbp
Origin-Software-Name: gntp.py
Notification-Title: A
Origin-Platform-Name: Darwin

DEBUG:gntp.notifier:From : localhost:23053 <<class 'gntp.core.GNTPError'>>
GNTP/1.0 -ERROR NONE
Error-Code: 402
Response-Action: NOTIFY
Error-Description: A is not registered for Python GNTP

ERROR:gntp.notifier:Invalid response: (u'402', u'A is not registered for Python GNTP')

... and same for B.

Edit: fixed by adding gntp.notifier.GrowlNotifier.register()

local image not working

Python 2.7 on Windows.

URL-based images work
setting image as <open('c:/home/hugo/work/woopra/woopra.png').read() > doesn't work...

The growl.notify() clause still returns true, but no notification is shown.

Support incoming password hashing other than MD5

Growl for Windows forwards packets to network destinations using AES encryption and a SHA256 password hash. gntp seems to only decode incoming hashes using MD5, regardless of what the packet header specifies.

Here's a snapshot of the data in the outgoing packet from GFW:

0000   47 4e 54 50 2f 31 2e 30 20 52 45 47 49 53 54 45  GNTP/1.0 REGISTE
0010   52 20 41 45 53 3a 35 35 36 37 43 44 43 39 44 35  R AES:5567CDC9D5
0020   32 43 42 45 33 42 33 41 41 35 32 37 30 30 41 39  2CBE3B3AA52700A9
0030   38 32 43 42 44 38 20 53 48 41 32 35 36 3a 45 34  82CBD8 SHA256:E4
0040   46 35 37 31 37 33 41 45 39 38 38 33 44 33 42 39  F57173AE9883D3B9
0050   32 34 37 33 45 38 35 35 33 32 31 39 37 32 41 30  2473E855321972A0
0060   38 41 30 44 43 33 38 32 39 44 41 41 39 31 44 41  8A0DC3829DAA91DA
0070   39 32 35 44 45 42 33 42 42 41 31 34 36 31 2e 32  925DEB3BBA1461.2
0080   31 32 42 34 44 35 30 31 37 42 36 31 33 45 44 0d  12B4D5017B613ED.
0090   0a 43 44 07 5a d1 92 5d 3d d6 35 aa 4a 21 6d 29  .CD.Z..]=.5.J!m)
00a0   1d 49 03 8b 41 a4 b8 fd 8b c2 f5 c0 2c c8 25 77  .I..A.......,.%w
00b0   fc 8a a8 2f 19 0a 9e ef 5d 9e b3 14 23 96 56 fd  .../....]...#.V.
00c0   b4 45 d2 e9 b3 8a ca 44 7f 1a fa 05 62 24 0e a3  .E.....D....b$..
00d0   3a b3 fb 75 91 30 ef bd a0 1f ff e4 c0 6d 32 42  :..u.0.......m2B
00e0   31 8b 66 f0 53 2a b0 58 8d 43 40 76 81 80 39 f6  1.f.S*[email protected].
00f0   ce 91 fd 53 6f a4 dd 49 1d 46 bc ab ab 6f 3d 07  ...So..I.F...o=.
0100   8d dd 3a aa 8e ed 90 1e 8c c2 15 fa 24 c8 02 cb  ..:.........$...
0110   ce 9b 24 10 e7 b9 39 fa a6 5b 03 f6 d8 43 8c 39  ..$...9..[...C.9
0120   1e f8 37 65 f8 c6 3b 13 09 08 5f 7b d7 53 cf 3a  ..7e..;..._{.S.:
0130   66 23 59 fd 02 83 66 9c e5 7c 55 65 6e 9d 9e d1  f#Y...f..|Uen...
0140   39 9a 29 24 87 cb 57 b7 a9 15 b8 3b 63 c8 56 64  9.)$..W....;c.Vd
0150   57 48 32 46 d8 93 90 6f 95 68 18 99 cb 4d 29 28  WH2F...o.h...M)(
0160   37 99 43 29 2e 03 dc 57 3b 1e 64 6e 79 b1 7d ab  7.C)...W;.dny.}.
0170   89 62 a7 75 f1 ba e4 9f 51 7a b4 7e ec 77 ee 1d  .b.u....Qz.~.w..
0180   38 c3 6d 5c 43 07 20 0a 12 59 e1 3d a4 aa 58 89  8.m\C. ..Y.=..X.
0190   48 cc 99 38 f3 57 e4 e4 b1 d5 75 cd 70 5a 59 6d  H..8.W....u.pZYm
01a0   3b 66 61 7f c2 0e 3b 14 18 8f 14 c1 93 40 04 d2  ;fa...;......@..
01b0   54 ff 2f 50 fc f1 3b 55 ae 5a d4 e1 2c e5 56 e6  T./P..;U.Z..,.V.
01c0   f9 c5 07 58 a8 c3 29 f7 a1 3d 0a 4b c7 71 cf df  ...X..)..=.K.q..
01d0   96 a0 03 2e d7 eb f7 cb a2 f4 38 b7 08 a8 ef 7a  ..........8....z
01e0   ec 4b 91 c9 7d 02 0a 33 cd 35 cd df b5 51 8b 8d  .K..}..3.5...Q..
01f0   49 66 ee 0a 54 59 5d f2 e5 c3 a6 6a 0c 38 6e f3  If..TY]....j.8n.
0200   b7 91 b3 45 ee c3 bb b1 ac 09 e0 b8 67 92 2a 92  ...E........g.*.
0210   f0 92 e9 96 fb 05 7d 2d 75 a2 08 f2 11 fa e5 0e  ......}-u.......
0220   9a 96 a0 93 cf 70 e8 0c 14 f5 9a 33 8a a2 34 2f  .....p.....3..4/
0230   d0 59 cc ca a3 f0 36 ed 9f 1c 73 63 b0 e8 37 13  .Y....6...sc..7.
0240   c4 ac ac 35 ab f4 72 02 1d 34 0d fd a3 01 64 35  ...5..r..4....d5
0250   8f a1 7f d3 7a c4 f5 6a 1e fe 7d d0 c9 bb e1 ab  ....z..j..}.....
0260   bb ac 24 f4 bb c1 fe 66 e6 53 10 08 ec 90 90 43  ..$....f.S.....C
0270   4d 0d 0a 0d 0a                                   M....

Test gntp.notifier fails

Hi, I installed gntp with pip on my machine running ubuntu 15.10. The installation looks ok, but when I type:

python -m gntp.notifier  #to check the installation

I get the following error:

INFO:__main__:Sending registration to localhost:23053
ERROR:__main__:Growl error
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/gntp/notifier.py", line 242, in mini
result = growl.register()
File "/usr/local/lib/python2.7/dist-packages/gntp/notifier.py", line 97, in register
return self._send('register', register)
File "/usr/local/lib/python2.7/dist-packages/gntp/notifier.py", line 204, in _send
raise errors.NetworkError(exc)
NetworkError: [Errno 111] Connection refused

Do you have an idea what is going on and how to fix it? Thank you

GNTPRegister accumulates notification classes

When creating a second GrowlNotifier object (needed when changing IP address), the new instance gets a merge of the previous last notification list and the new notification list.
The result is that the Growl server refuses the new list because it contains duplicates.
The only work-around I found was to reset the class attributes before creating a new instance.

GNTPRegister.notifications = []
GNTPRegister.headers = {}
growler = GrowlNotifier(.....)

I had a hard time following where class attributes and where instance attributes were used.
Python class attributes are tricky monsters.

problem when running growlnotifier

After installing growl. when I am checking "python -m gntp.notifier" I am getting errors.

C:\Users\ZEI>python -m gntp.notifier
INFO:main:Sending registration to localhost:23053
ERROR:main:Growl error
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\gntp\notifier.py", line 242, in mini
result = growl.register()
File "C:\Python27\lib\site-packages\gntp\notifier.py", line 97, in register
return self._send('register', register)
File "C:\Python27\lib\site-packages\gntp\notifier.py", line 204, in _send
raise errors.NetworkError(exc)
NetworkError: [Errno 10061] No connection could be made because the target machi
ne actively refused it

`callback` parameter does nothing

Clicking a notification doesn't open the callback URL in the browser. The code I'm using is here: githubfeed.py.

But even the sample code has the same problem (at least on my system):

from gntp.notifier import mini
# Send a simple growl message with mostly default values
mini("Here's a quick message", callback="http://github.com/")

Is there any configuration/setting I'm missing?

Tests failing

Hey, I wonder if there is anything I should do before running test suite (tox). Currently I get 1 error (see output below):

lukasz@macbook ⮀ ~/develop/workspace/gntp ⮀ ⭠ master± ⮀ tox -e py27
GLOB sdist-make: /Users/lukasz/develop/workspace/gntp/setup.py
py27 sdist-reinst: /Users/lukasz/develop/workspace/gntp/.tox/dist/gntp-0.9.zip
py27 runtests: commands[0]
...............F......
======================================================================
FAIL: Fake hash should not work
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/lukasz/develop/workspace/gntp/gntp/test/test_hash.py", line 43, in test_fake
    self.assertRaises(UnsupportedError, self._hash, 'fake-hash')
AssertionError: UnsupportedError not raised
-------------------- >> begin captured logging << --------------------
gntp.notifier: INFO: Sending registration to localhost:23053
gntp.notifier: DEBUG: To : localhost:23053 <<class 'gntp.GNTPRegister'>>
GNTP/1.0 REGISTER NONE
Application-Name: GNTP unittest
Origin-Platform-Version: Darwin-12.2.0-x86_64-i386-64bit
Origin-Software-Version: 0.9
Origin-Machine-Name: Lukaszs-MacBook-Pro.local
Origin-Software-Name: gntp.py
Origin-Platform-Name: Darwin
Notifications-Count: 1

Notification-Enabled: True
Notification-Name: Testing


gntp.notifier: DEBUG: From : localhost:23053 <<class 'gntp.GNTPOK'>>
GNTP/1.0 -OK NONE
Response-Action: REGISTER


gntp.notifier: INFO: Sending notification [Testing] to localhost:23053
gntp.notifier: DEBUG: To : localhost:23053 <<class 'gntp.GNTPNotice'>>
GNTP/1.0 NOTIFY NONE
Application-Name: GNTP unittest
Notification-Name: Testing
Notification-Text: fake-hash
Origin-Platform-Version: Darwin-12.2.0-x86_64-i386-64bit
Origin-Software-Version: 0.9
Origin-Machine-Name: Lukaszs-MacBook-Pro.local
Origin-Software-Name: gntp.py
Notification-Title: Unittest Title
Origin-Platform-Name: Darwin


gntp.notifier: DEBUG: From : localhost:23053 <<class 'gntp.GNTPOK'>>
GNTP/1.0 -OK NONE
Response-Action: NOTIFY


--------------------- >> end captured logging << ---------------------

----------------------------------------------------------------------
Ran 22 tests in 1.905s

FAILED (failures=1)
ERROR: InvocationError: '/Users/lukasz/develop/workspace/gntp/.tox/py27/bin/nosetests'
______________________________________________________________________________ summary ______________________________________________________________________________
ERROR:   py27: commands failed

Support click callbacks

Right now only url callbacks are supported. It would be great to be able to click through the notification and bring up the appropriate part of the application.

Selecting icon is broken?

I'm having trouble getting icons to display with GNTP, using the following code:

#!/usr/bin/env python2.7

import gntp.notifier

growl = gntp.notifier.GrowlNotifier(
    applicationName = "My Application Name",
    notifications = ["New Updates","New Messages"],
    defaultNotifications = ["New Messages"],
    # hostname = "computer.example.com", # Defaults to localhost
    # password = "abc123" # Defaults to a blank password
)
growl.register()

# Send one message
growl.notify(
    noteType = "New Messages",
    title = "You have a new message",
    description = "A longer message description",
    icon = "http://upload.wikimedia.org/wikipedia/commons/8/89/Exquisite-khelpcenter.png",
    sticky = False,
    priority = 1,
)

I'm running Mac Lion, 10.7.2, with Growl 1.3.3 from the App Store. The notification pops up with correct title and description, but the generic orb with lines and dots image. I get the same error when I try to reference local icons, such as /Users/akerl/Downloads/Exquisite-khelpcenter.png.

Am I doing something wrong, or is there a setting I have to adjust to allow this module to specify an icon?

Error sending notifications

Hi, I have ubuntu server 12.04 and python 2.7
I'm triying to send msgs by gntp to my windows 7 computer with growl program but when i run gntp I get this msg
Traceback (most recent call last):
File "./growl", line 75, in
result = growl.register()
File "/usr/local/lib/python2.7/dist-packages/gntp/notifier.py", line 103, in register
return self._send('register', register.encode())
File "/usr/local/lib/python2.7/dist-packages/gntp/notifier.py", line 152, in _send
s.connect((self.hostname, self.port))
File "/usr/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)

Do you know why or what i must to do to fix it?

Thank you

gntp fails intermittently on OS X 10.9.0

Running python -m gntp.notifier alternates between:

INFO:__main__:Sending notification [Message] to localhost:23053

and:

 ERROR:__main__:Invalid response: (u'303', u'Growl does not have enough information in (null) to parse')

In our production code using gntp, a third alternating message occurs:

ERROR:gntp.notifier:Invalid response: (u'400', u'Unsupported encryption type, NONE@/\x07')

There's no pattern to how these messages are sent - multiple fails, then a success.

Crash when using non-US ASCII characters

When setting notification texts containing non-US ASCII characters(e.g. é) in "GrowlNotifier", sending actual messages will fail.
All texts are internally converted to Unicode by GNTPRegister, but the "send" method of "GrowlNotifier" tries to send Unicode strings directly, without first converting to UTF-8.

Changing line 126 to s.send(data.encode('utf-8', 'replace')) should do the trick.

Seemingly unable to install with pipsi

$ pipsi install gntp
Running virtualenv with interpreter /Users/paultraylor/.local/venvs/pipsi/bin/python
Using real prefix '/System/Library/Frameworks/Python.framework/Versions/2.7'
New python executable in /Users/paultraylor/.local/venvs/gntp/bin/python
Installing setuptools, pip, wheel...done.
Collecting gntp
  Using cached gntp-1.0.3-py2-none-any.whl
Installing collected packages: gntp
Successfully installed gntp-1.0.3
Did not find any scripts.  Uninstalling.

Need to test, but my initial suspicion is that the bundled wheel file isn't setup correctly so it can't find the entry point.

Custom Attributes support

Are there any examples of how to create "Custom Attributes"?

Looking at the the "Growl for Windows - Application Integration Guide", I can see it defined as:

Custom Attributes

In addition to the defined properties that are sent in a GNTP request, you can also include additional custom properties. Consider a music player that wants to send additional track information such as artist, album, genre, duration, and rating – these are properties specific to the sending application and thus not part of the defined notification spec, but could be useful information to display nonetheless.
Custom attributes come in two flavors: text and binary. To add either type:

notification.CustomTextAttributes.Add("Rating", "5 Stars");
notification.CustomTextAttributes.Add("Genre", "Alternative");
notification.CustomBinaryAttributes.Add("Sound", new BinaryData(new byte[] { ...bytes... }));

Custom attributes can be attached to an Application, NotificationType, or Notification and are inherited down the chain. Any custom attributes are passed to the display that handles the notification. While most generic displays will not recognize these custom values and ignore them, a custom display could be written that can take advantage of the extended information.

I'd like to forward some notifications to the "Webhook" plugin (http://www.growlforwindows.com/gfw/forwarders/webhook), and pass along device ID's and other variables needed for the pushingbox.com or Notifrier APIs.

If Custom Attributes aren't supported, I'll just use two scripts, one to send a notification to pushingbox and another to generate the Growl notification.

Thanks!

Simple "one-line" Growler

Have a simple one-line growler function that assumes more defaults and combines the register and notification steps for simple notifications.

Example

from gntp.simple import notify
# Default example assumes localhost with no password
# Internally will use GrowlNotifier and call both the register() and notify() methods
notify('ApplicationName', 'Notification Name', 'Notification Message')

Cannot send notification icon

Tried:

gntp -m foobar --image "http://www.givedomainnames.com/images/success_icon.png"

also tried local path to the image.

Is this a bug or am I doing something wrong?

On a OSX 10.8.2, Growl 2.0.1

gntp fails on OS X 10.9.1

With Growl 2.1.3 and gntp 1.0.2:

python -m gntp.notifier
INFO:__main__:Sending registration to localhost:23053
INFO:__main__:Sending notification [Message] to localhost:23053
ERROR:__main__:Invalid response: (u'404', u'Note Message in PythonMini was disabled by the user')

Happens every time.

Some intermittent connection errors on 10.9 Mavericks (multiple errors)

I recently updated to Maverick's and I've re-installed per the instructions.

I can run "python -m gntp.notifier" over and over again and get one of 3 different error message each time. Some times, amazingly, it works with no error. I can literally just up-arrow and [return] and get a different error. 5% of the time, it works.

Here are the error variants:

  • This error happens 80% of the time: ERROR:main:Invalid response: (u'303', u'Growl does not have enough information in (null) to parse')
  • This error happens 10% of the time: ERROR:main:Invalid response: (u'400', u'Missing, malformed, or invalid key hash string')
  • This error happens 5% of the time: ERROR:main:Invalid response: (u'400', u'Unsupported encryption type, NONE\x1b')

This was not an issue prior to upgrading.

Disable captured logging

Hi,

I'm building a small library to send notifications for successful/failed tests via GNTP. I've written a small nose plugin that when the nose suite finishes is sends the desired message.

My issue is that when a test fails the GNTP library outputs some debugging information similar to this:

-------------------- >> begin captured logging << --------------------
gntp.notifier: INFO: Sending registration to localhost:23053
gntp.notifier: DEBUG: To : localhost:23053 <<class 'gntp.GNTPRegister'>>
GNTP/1.0 REGISTER NONE
Application-Name: Success!
Origin-Platform-Version: Darwin-12.2.1-x86_64-i386-64bit
Origin-Software-Version: 0.8
Origin-Machine-Name: Bogdans-MacBook-Air.local
...
gntp.notifier: DEBUG: From : localhost:23053 <<class 'gntp.GNTPOK'>>
GNTP/1.0 -OK NONE
Response-Action: NOTIFY

Is there a way to suppress this output as it pollutes the nose output for the tests ?

Thanks and thanks for building this awesome library!

sticky = True not working

Hi,

I'm a pretty big growl user on windows and have finally decided to ditch windows and move to Linux. I write a lot of python scripts that send GNTP and use the sticky = True so I never miss messages. However using your sample code only changing the sticky property I was unable to make the window stay.

I'm using Ubuntu 12.04, gnome classic, growl for linux 0.6.8 and python 2.7.3

Thanks,

James

ImportError: No module named gntp.notifier

Hello. I've installed Growl, GNTP and verified install using:

python -m gntp.notifier

Which displays a growl. However my script throws an error:

Traceback (most recent call last):
File "./eventcmd", line 18, in
from gntp.notifier import mini
ImportError: No module named gntp.notifier

Screenshot of script: http://dl.dpeck.net/1je9k

Thanks in advance for any help!

Also this is Yosemite, not sure if that makes a difference.

Internal logging is invisible: suggestion to fix

If an error or warning is generated, gntp writes a message using the 'logging' library. But the calling program just gets a not very descriptive exception. This can be remedied by creating a logging instance in the calling program like:

import logging
logging.basicConfig(level=logging.INFO)

Maybe this can be added to the readme?

gntp.errors.NetworkError: [Errno 61] Connection refused

Hello I am getting this error. Please help me. I am new to this.

import gntp.notifier
gntp.notifier.mini("Here's a quick message")

Error:

Growl error
Traceback (most recent call last):
  File "/Users/mayukhsarkar/anaconda3/lib/python3.6/site-packages/gntp/notifier.py", line 197, in _send
    s.connect((self.hostname, self.port))
ConnectionRefusedError: [Errno 61] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/mayukhsarkar/anaconda3/lib/python3.6/site-packages/gntp/notifier.py", line 243, in mini
    result = growl.register()
  File "/Users/mayukhsarkar/anaconda3/lib/python3.6/site-packages/gntp/notifier.py", line 98, in register
    return self._send('register', register)
  File "/Users/mayukhsarkar/anaconda3/lib/python3.6/site-packages/gntp/notifier.py", line 205, in _send
    raise errors.NetworkError(exc)
gntp.errors.NetworkError: [Errno 61] Connection refused

Example Usage Correction?

I couldn't get the example usage to work, until I amended it. I also recommend setting the address as localhost, as that is the most likely type of test someone will carry out first.

import gntp.notifier
growl = gntp.notifier.GrowlNotifier(
applicationName = "My Application Name",
notifications = ["New Updates","New Messages"],
defaultNotifications = ["New Messages"],
hostname = "localhost",
password = "foo"
)
growl.register()

result = growl.notify(
noteType = "New Messages",
title = "You have a new message",
description = "A longer message description",
icon = "http://example.com/icon.png",
sticky = False,
priority = 1
)

Timeout when sending to Growl 2.0 when including binary data

Looks like we're not putting on the final crlf when sending messages with binary data.

  File "build/bdist.macosx-10.7-intel/egg/gntp/notifier.py", line 178, in notify
    return self._send('notify', notice)
  File "build/bdist.macosx-10.7-intel/egg/gntp/notifier.py", line 223, in _send
    recv_data = s.recv(1024)
timeout: timed out

I made a gist while testing but I want to make sure to wrap a proper test around this and test against Growl 1.4 and GfW

https://gist.github.com/3514969

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.