Private GIT

Skip to content
Snippets Groups Projects
Commit 8d22eb53 authored by miigotu's avatar miigotu
Browse files

Merge pull request #2560 from SiCKRAGETV/pushover-lint

Fix some out of order paramters in calls to private pushover notifier…
parents f187c9d6 561dde90
No related branches found
No related tags found
No related merge requests found
...@@ -29,10 +29,10 @@ from sickrage.helper.exceptions import ex ...@@ -29,10 +29,10 @@ from sickrage.helper.exceptions import ex
API_URL = "https://api.pushover.net/1/messages.json" API_URL = "https://api.pushover.net/1/messages.json"
# pylint: disable=W0232,C1001
class PushoverNotifier: class PushoverNotifier:
def test_notify(self, userKey=None, apiKey=None): def test_notify(self, userKey=None, apiKey=None):
return self._notifyPushover("This is a test notification from SickRage", 'Test', userKey, apiKey, force=True) return self._notifyPushover("This is a test notification from SickRage", 'Test', userKey=userKey, apiKey=apiKey, force=True)
def _sendPushover(self, msg, title, sound=None, userKey=None, apiKey=None): def _sendPushover(self, msg, title, sound=None, userKey=None, apiKey=None):
""" """
...@@ -40,9 +40,9 @@ class PushoverNotifier: ...@@ -40,9 +40,9 @@ class PushoverNotifier:
msg: The message to send (unicode) msg: The message to send (unicode)
title: The title of the message title: The title of the message
userKey: The pushover user id to send the message to (or to subscribe with)
sound: The notification sound to use sound: The notification sound to use
userKey: The pushover user id to send the message to (or to subscribe with)
apiKey: The pushover api key to use
returns: True if the message succeeded, False otherwise returns: True if the message succeeded, False otherwise
""" """
...@@ -63,8 +63,7 @@ class PushoverNotifier: ...@@ -63,8 +63,7 @@ class PushoverNotifier:
# send the request to pushover # send the request to pushover
try: try:
if sickbeard.PUSHOVER_SOUND != "default": if sickbeard.PUSHOVER_SOUND != "default":
args = { args = {"token": apiKey,
"token": apiKey,
"user": userKey, "user": userKey,
"title": title.encode('utf-8'), "title": title.encode('utf-8'),
"message": msg.encode('utf-8'), "message": msg.encode('utf-8'),
...@@ -75,8 +74,7 @@ class PushoverNotifier: ...@@ -75,8 +74,7 @@ class PushoverNotifier:
} }
else: else:
# sound is default, so don't send it # sound is default, so don't send it
args = { args = {"token": apiKey,
"token": apiKey,
"user": userKey, "user": userKey,
"title": title.encode('utf-8'), "title": title.encode('utf-8'),
"message": msg.encode('utf-8'), "message": msg.encode('utf-8'),
...@@ -109,7 +107,7 @@ class PushoverNotifier: ...@@ -109,7 +107,7 @@ class PushoverNotifier:
elif e.code == 401: elif e.code == 401:
#HTTP status 401 if the user doesn't have the service added #HTTP status 401 if the user doesn't have the service added
subscribeNote = self._sendPushover(msg, title, userKey, apiKey) subscribeNote = self._sendPushover(msg, title, sound=sound, userKey=userKey, apiKey=apiKey)
if subscribeNote: if subscribeNote:
logger.log("Subscription sent", logger.DEBUG) logger.log("Subscription sent", logger.DEBUG)
return True return True
...@@ -151,12 +149,13 @@ class PushoverNotifier: ...@@ -151,12 +149,13 @@ class PushoverNotifier:
def _notifyPushover(self, title, message, sound=None, userKey=None, apiKey=None, force=False): def _notifyPushover(self, title, message, sound=None, userKey=None, apiKey=None, force=False):
""" """
Sends a pushover notification based on the provided info or SB config Sends a pushover notification based on the provided info or SR config
title: The title of the notification to send title: The title of the notification to send
message: The message string to send message: The message string to send
userKey: The userKey to send the notification to
sound: The notification sound to use sound: The notification sound to use
userKey: The userKey to send the notification to
apiKey: The apiKey to use to send the notification
force: Enforce sending, for instance for testing force: Enforce sending, for instance for testing
""" """
...@@ -166,7 +165,7 @@ class PushoverNotifier: ...@@ -166,7 +165,7 @@ class PushoverNotifier:
logger.log("Sending notification for " + message, logger.DEBUG) logger.log("Sending notification for " + message, logger.DEBUG)
return self._sendPushover(message, title, userKey, apiKey) return self._sendPushover(message, title, sound=sound, userKey=userKey, apiKey=apiKey)
notifier = PushoverNotifier notifier = PushoverNotifier
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment