Skip to content

Instantly share code, notes, and snippets.

@iamsilvio
Created March 23, 2013 12:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamsilvio/5227648 to your computer and use it in GitHub Desktop.
Save iamsilvio/5227648 to your computer and use it in GitHub Desktop.
quick and dirty prowl push with proxy (keep care to specify a real exception to catch and log if needed)
import urllib
import urllib2
API_URL = 'https://api.prowlapp.com/publicapi/add'
API_KEY = 'xxxxxxxxxxxxxxxxxxx'
PROXY = 'xxx.xxx.xxx.xxx:xxxx'
def push():
try:
req = urllib2.Request(API_URL)
if not req.has_proxy():
req.set_proxy(PROXY, 'https')
data = {'apikey': API_KEY,
'application': 'xxxxx',
'event': 'xxxx',
'description': 'xxxxx',
'priority': 0}
req.add_data(urllib.urlencode(data))
urllib2.urlopen(req)
except Exception:
print('-')
pass
push()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment