Created
May 11, 2012 08:42
-
-
Save xlson/2658443 to your computer and use it in GitHub Desktop.
Prowl notifcation script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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