Pyrowl is a simple python module for the Prowl API.
Prowl is the Growl client for the iPhone OS. Notifications from your Mac or Windows computer are sent to your iPhone or iPod touch using push. Prowl has an extensive API, which allows your scripts to integrate beautifully. (source: http://www.prowlapp.com/)
First, import the module:
import pyrowl
Create a Pyrowl simple instance:
p = pyrowl.Pyrowl( "apikey(s)", "providerkey")
Both apikey(s) and providerkey are optionnal. If you'd like to add just one API key, set it as string, if you want more, just provide a list of API key strings.
p = pyrowl.Pyrowl(['apikey1','apikey2]) # multiple API keys
p = pyrowl.Pyrowl("apikey1","providerkey") # 1 API key with a providerkey
For more flexible usage, you can add and remove keys:
p.addkey("apikey1")
p.addkey(["apikey2","apikey3"])
Or set or change the providerkey
p.providerkey("providerkey")
p.push(application, event, description, (opt) priority, (opt) batch mode)
Application is your message generating application name (limited to 256)
ex: my music player
Event is the event name (limited to 1024)
ex: switched to next track
The description is the payload of your message (limited to 10000 (10k)) ex:
Playing next song, Blah Blah Blah
Artist: blah blah
Album: blah blah
Track: 18/24
Priority goes from -2 (lowest) to 2 (highest). the default priority is 0 (normal)
Batch mode is a boolean value to set if you'd like to push the same message to multiple API keys 5 by 5 (as the actual verion of prowl API allows you). Thias can reduce the number of call you make to the API which are limited.
The push method returns a dict containing different values depending of the success of you call:
you'll have in the dict those keys:
type: success
code: the HTTP like code (200 if success)
remaining: the number of API call you can to until the reset
resetdate: which is the date of the remaining reset (UTC)
For wathever reason, you call failed, the dict key "message" will contains the erro message returned by Prowl API. You'll find those keys:
code: 400, 401, 405, 406 or 500 (depends of the error kind)
message: API error message
For the code description, please refer to Prowl API documentation for more informations
The return keys will be:
code: 600
type: pyrowlerror
message: the exception message