From fa6e34eb86e61509db3108137981ae810729a82c Mon Sep 17 00:00:00 2001 From: Chris Caron Date: Wed, 6 Feb 2019 20:45:00 -0500 Subject: [PATCH] Removal of palot:// as service is no longer available; refs #46 --- README.md | 1 - apprise/plugins/NotifyPushalot.py | 168 ------------------------------ apprise/plugins/__init__.py | 3 +- test/test_api.py | 5 +- test/test_rest_plugins.py | 44 -------- 5 files changed, 3 insertions(+), 218 deletions(-) delete mode 100644 apprise/plugins/NotifyPushalot.py diff --git a/README.md b/README.md index 5ba74e69..9d3e25f8 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,6 @@ The table below identifies the services this tool supports and some example serv | [Matrix](https://github.com/caronc/apprise/wiki/Notify_matrix) | matrix:// | (TCP) 443 | matrix://token
matrix://user@token
matrixs://token?mode=slack
matrixs://user@token | [Mattermost](https://github.com/caronc/apprise/wiki/Notify_mattermost) | mmost:// | (TCP) 8065 | mmost://hostname/authkey
mmost://hostname:80/authkey
mmost://user@hostname:80/authkey
mmost://hostname/authkey?channel=channel
mmosts://hostname/authkey
mmosts://user@hostname/authkey
| [Prowl](https://github.com/caronc/apprise/wiki/Notify_prowl) | prowl:// | (TCP) 443 | prowl://apikey
prowl://apikey/providerkey -| [Pushalot](https://github.com/caronc/apprise/wiki/Notify_pushalot) | palot:// | (TCP) 443 | palot://authorizationtoken | [PushBullet](https://github.com/caronc/apprise/wiki/Notify_pushbullet) | pbul:// | (TCP) 443 | pbul://accesstoken
pbul://accesstoken/#channel
pbul://accesstoken/A_DEVICE_ID
pbul://accesstoken/email@address.com
pbul://accesstoken/#channel/#channel2/email@address.net/DEVICE | [Pushjet](https://github.com/caronc/apprise/wiki/Notify_pushjet) | pjet:// | (TCP) 80 | pjet://secret
pjet://secret@hostname
pjet://secret@hostname:port
pjets://secret@hostname
pjets://secret@hostname:port
Note: if no hostname defined https://api.pushjet.io will be used | [Pushover](https://github.com/caronc/apprise/wiki/Notify_pushover) | pover:// | (TCP) 443 | pover://user@token
pover://user@token/DEVICE
pover://user@token/DEVICE1/DEVICE2/DEVICEN
_Note: you must specify both your user_id and token_ diff --git a/apprise/plugins/NotifyPushalot.py b/apprise/plugins/NotifyPushalot.py deleted file mode 100644 index 25513ee0..00000000 --- a/apprise/plugins/NotifyPushalot.py +++ /dev/null @@ -1,168 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2019 Chris Caron -# All rights reserved. -# -# This code is licensed under the MIT License. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files(the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and / or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions : -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. - -import re -import requests -from json import dumps - -from .NotifyBase import NotifyBase -from .NotifyBase import HTTP_ERROR_MAP -from ..common import NotifyImageSize - -# Extend HTTP Error Messages -PUSHALOT_HTTP_ERROR_MAP = HTTP_ERROR_MAP.copy() -PUSHALOT_HTTP_ERROR_MAP.update({ - 406: 'Message throttle limit hit.', - 410: 'AuthorizedToken is no longer valid.', -}) - -# Used to validate Authorization Token -VALIDATE_AUTHTOKEN = re.compile(r'[A-Za-z0-9]{32}') - - -class NotifyPushalot(NotifyBase): - """ - A wrapper for Pushalot Notifications - """ - - # The default descriptive name associated with the Notification - service_name = 'Pushalot' - - # The services URL - service_url = 'https://pushalot.com/' - - # The default protocol is always secured - secure_protocol = 'palot' - - # A URL that takes you to the setup/help of the specific protocol - setup_url = 'https://github.com/caronc/apprise/wiki/Notify_pushalot' - - # Pushalot uses the http protocol with JSON requests - notify_url = 'https://pushalot.com/api/sendmessage' - - # Allows the user to specify the NotifyImageSize object - image_size = NotifyImageSize.XY_72 - - def __init__(self, authtoken, is_important=False, **kwargs): - """ - Initialize Pushalot Object - """ - super(NotifyPushalot, self).__init__(**kwargs) - - # Is Important Flag - self.is_important = is_important - - self.authtoken = authtoken - # Validate authtoken - if not VALIDATE_AUTHTOKEN.match(authtoken): - self.logger.warning( - 'Invalid Pushalot Authorization Token Specified.' - ) - raise TypeError( - 'Invalid Pushalot Authorization Token Specified.' - ) - - def notify(self, title, body, notify_type, **kwargs): - """ - Perform Pushalot Notification - """ - - headers = { - 'User-Agent': self.app_id, - 'Content-Type': 'application/json' - } - - # prepare JSON Object - payload = { - 'AuthorizationToken': self.authtoken, - 'IsImportant': self.is_important, - 'Title': title, - 'Body': body, - 'Source': self.app_id, - } - - image_url = self.image_url(notify_type) - if image_url: - payload['Image'] = image_url - - self.logger.debug('Pushalot POST URL: %s (cert_verify=%r)' % ( - self.notify_url, self.verify_certificate, - )) - self.logger.debug('Pushalot Payload: %s' % str(payload)) - try: - r = requests.post( - self.notify_url, - data=dumps(payload), - headers=headers, - verify=self.verify_certificate, - ) - - if r.status_code != requests.codes.ok: - # We had a problem - try: - self.logger.warning( - 'Failed to send Pushalot notification: ' - '%s (error=%s).' % ( - PUSHALOT_HTTP_ERROR_MAP[r.status_code], - r.status_code)) - - except KeyError: - self.logger.warning( - 'Failed to send Pushalot notification ' - '(error=%s).' % r.status_code) - - # Return; we're done - return False - - else: - self.logger.info('Sent Pushalot notification.') - - except requests.RequestException as e: - self.logger.warning( - 'A Connection error occured sending Pushalot notification.') - self.logger.debug('Socket Exception: %s' % str(e)) - - # Return; we're done - return False - - return True - - @staticmethod - def parse_url(url): - """ - Parses the URL and returns enough arguments that can allow - us to substantiate this object. - - """ - results = NotifyBase.parse_url(url) - - if not results: - # We're done early as we couldn't load the results - return results - - # Apply our settings now - results['authtoken'] = results['host'] - - return results diff --git a/apprise/plugins/__init__.py b/apprise/plugins/__init__.py index 30675004..87a32904 100644 --- a/apprise/plugins/__init__.py +++ b/apprise/plugins/__init__.py @@ -40,7 +40,6 @@ from .NotifyJSON import NotifyJSON from .NotifyMatrix import NotifyMatrix from .NotifyMatterMost import NotifyMatterMost from .NotifyProwl import NotifyProwl -from .NotifyPushalot import NotifyPushalot from .NotifyPushBullet import NotifyPushBullet from .NotifyPushjet.NotifyPushjet import NotifyPushjet from .NotifyPushover import NotifyPushover @@ -68,7 +67,7 @@ __all__ = [ 'NotifyBoxcar', 'NotifyEmail', 'NotifyEmby', 'NotifyDiscord', 'NotifyFaast', 'NotifyGnome', 'NotifyGrowl', 'NotifyIFTTT', 'NotifyJoin', 'NotifyJSON', 'NotifyMatrix', 'NotifyMatterMost', 'NotifyProwl', - 'NotifyPushalot', 'NotifyPushBullet', 'NotifyPushjet', 'NotifyPushover', + 'NotifyPushBullet', 'NotifyPushjet', 'NotifyPushover', 'NotifyRocketChat', 'NotifySlack', 'NotifyStride', 'NotifyToasty', 'NotifyTwitter', 'NotifyTelegram', 'NotifyXBMC', 'NotifyXML', 'NotifyWindows', diff --git a/test/test_api.py b/test/test_api.py index c16bdc03..c903d76a 100644 --- a/test/test_api.py +++ b/test/test_api.py @@ -65,19 +65,18 @@ def test_apprise(): servers = [ 'faast://abcdefghijklmnop-abcdefg', 'kodi://kodi.server.local', - 'palot://1f418df7577e32b89ac6511f2eb9aa68', ] a = Apprise(servers=servers) # 3 servers loaded - assert(len(a) == 3) + assert(len(a) == 2) # We can add another server assert( a.add('mmosts://mattermost.server.local/' '3ccdd113474722377935511fc85d3dd4') is True) - assert(len(a) == 4) + assert(len(a) == 3) # We can empty our set a.clear() diff --git a/test/test_rest_plugins.py b/test/test_rest_plugins.py index 63b41df8..c943fd58 100644 --- a/test/test_rest_plugins.py +++ b/test/test_rest_plugins.py @@ -744,50 +744,6 @@ TEST_URLS = ( 'test_requests_exceptions': True, }), - ################################## - # NotifyPushalot - ################################## - ('palot://', { - 'instance': None, - }), - # AuthToken - ('palot://%s' % ('a' * 32), { - 'instance': plugins.NotifyPushalot, - }), - # AuthToken, no image - ('palot://%s' % ('a' * 32), { - 'instance': plugins.NotifyPushalot, - # don't include an image by default - 'include_image': False, - }), - # Invalid AuthToken - ('palot://%s' % ('a' * 24), { - # Missing a channel - 'instance': TypeError, - }), - # AuthToken + bad url - ('palot://:@/', { - 'instance': None, - }), - ('palot://%s' % ('a' * 32), { - 'instance': plugins.NotifyPushalot, - # force a failure - 'response': False, - 'requests_response_code': requests.codes.internal_server_error, - }), - ('palot://%s' % ('a' * 32), { - 'instance': plugins.NotifyPushalot, - # throw a bizzare code forcing us to fail to look it up - 'response': False, - 'requests_response_code': 999, - }), - ('palot://%s' % ('a' * 32), { - 'instance': plugins.NotifyPushalot, - # Throws a series of connection and transfer exceptions when this flag - # is set and tests that we gracfully handle them - 'test_requests_exceptions': True, - }), - ################################## # NotifyPushBullet ##################################