Skip to content

Instantly share code, notes, and snippets.

@xlson
Created May 11, 2012 08:42
Show Gist options
  • Save xlson/2658443 to your computer and use it in GitHub Desktop.
Save xlson/2658443 to your computer and use it in GitHub Desktop.
Prowl notifcation script
#!/usr/bin/python
from optparse import OptionParser
import sys
import urllib2
import urllib
description = sys.stdin.read()
parser = OptionParser()
parser.add_option('-k', '--key', dest='key',
help='prowl api-key')
parser.add_option('-a', '--application', dest='app',
help='the application responsible for the message')
parser.add_option('-e', '--event', dest='event',
help='the event message')
parser.add_option('-p', '--priority', dest='prio', default='0',
help='message priority')
(options, args) = parser.parse_args()
def build_prowl_url(key, app, event, desc, prio):
params = urllib.urlencode({'apikey': key, 'application': app, 'event': event, 'priority': prio, 'description': desc})
return 'https://api.prowlapp.com/publicapi/add?' + params
url = build_prowl_url(options.key, options.app, options.event, description, options.prio)
urllib2.urlopen(url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment