Updated pushover to use requests lib

This commit is contained in:
rembo10
2015-06-12 00:08:35 -07:00
parent ebd6d3f3f9
commit 1b998e9d01
3 changed files with 11 additions and 19 deletions

View File

@@ -6,6 +6,7 @@ Released xx xxx 2015
Highlights:
*Improved: Specify whether to delete folders when force post-processing
*Improved: Convert target bitrate to vbr preset for what.cd searching
*Improved: Switched Pushover to requests lib
The full list of commits can be found [here](https://github.com/rembo10/headphones/compare/v0.5.6...v0.5.7).

View File

@@ -583,7 +583,7 @@ class PUSHOVER(object):
if not headphones.CONFIG.PUSHOVER_ENABLED:
return
http_handler = HTTPSConnection("api.pushover.net")
url = "https://api.pushover.net/1/messages.json"
data = {'token': self.application_token,
'user': headphones.CONFIG.PUSHOVER_KEYS,
@@ -591,25 +591,16 @@ class PUSHOVER(object):
'message': message.encode("utf-8"),
'priority': headphones.CONFIG.PUSHOVER_PRIORITY}
http_handler.request("POST",
"/1/messages.json",
headers={'Content-type': "application/x-www-form-urlencoded"},
body=urlencode(data))
response = http_handler.getresponse()
request_status = response.status
logger.debug(u"Pushover response status: %r" % request_status)
logger.debug(u"Pushover response headers: %r" % response.getheaders())
logger.debug(u"Pushover response body: %r" % response.read())
headers = {'Content-type': "application/x-www-form-urlencoded"}
if request_status == 200:
logger.info(u"Pushover notifications sent.")
return True
elif request_status >= 400 and request_status < 500:
logger.info(u"Pushover request failed: %s" % response.reason)
return False
response = request.request_response(url, method="POST", headers=headers, data=data)
if response:
logger.info(u"Pushover notifications sent.")
return True
else:
logger.info(u"Pushover notification failed.")
return False
logger.error(u"Pushover notification failed.")
return False
def updateLibrary(self):
#For uniformity reasons not removed

View File

@@ -1430,7 +1430,7 @@ class WebInterface(object):
logger.info(u"Sending Pushover notification")
pushover = notifiers.PUSHOVER()
result = pushover.notify("hooray!", "This is a test")
return result
return str(result)
class Artwork(object):
@cherrypy.expose