Skip to content

Commit

Permalink
Few bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Burch committed Jul 8, 2009
1 parent b125e69 commit 6255141
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README
Expand Up @@ -17,5 +17,5 @@ Basic working module

Todo:
Add priority
Add API key verification
Test against character-limits.
Test against character-limits.
More detailed Exceptions based on the returned XML document
25 changes: 16 additions & 9 deletions prowlpy.py
Expand Up @@ -12,13 +12,12 @@
import httplib2
import urllib

API_DOMAIN = 'https://prowl.weks.net/publicapi'


API_DOMAIN = 'https://prowl.weks.net/publicapi/add'
class Prowl(object):
def __init__(self,apikey,username=None,password=None):
self.apikey = apikey
self.username = username #currently not in use
self.username = username #Currently not in use
self.password = password #Currently not in use

def post(self,application=None,event=None,description=None):
Expand All @@ -32,15 +31,23 @@ def post(self,application=None,event=None,description=None):
# URL-encode and string-ify keywords. Better type/content testing is needed here
application = urllib.quote(str(application))
event = urllib.quote(str(event))
desciption = urllib.quote(str(description))
description = urllib.quote(str(description))

verify_resp,verify_content = h.request("%s/verify?apikey=%s" % \
(API_DOMAIN,self.apikey))

if verify_resp['status']!='200':
raise Exception("Invalid API Key %s" % verify_content)

# Perform the request and get the response headers and content (Content should be blank for now)
resp,content = h.request("%s?application=%s&event=%s&description=%s&apikey=%s" \
# Perform the request and get the response headers and content
resp,content = h.request("%s/add?application=%s&event=%s&description=%s&apikey=%s" \
% (API_DOMAIN,application, event, description,self.apikey))
url = "%s/add?application=%s&event=%s&description=%s&apikey=%s" \
% (API_DOMAIN,application, event, description,self.apikey)

if(resp['status']=='200'):
if resp['status']=='200':
return True
elif(resp['status']=='401'):
raise Exception("Auth Failed")
elif resp['status']=='401':
raise Exception("Auth Failed %s" % url)
else:
raise Exception("Failed")

0 comments on commit 6255141

Please sign in to comment.