simplepush 2.2.3__tar.gz → 2.2.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {simplepush-2.2.3/src/simplepush.egg-info → simplepush-2.2.4}/PKG-INFO +6 -2
- {simplepush-2.2.3 → simplepush-2.2.4}/pyproject.toml +1 -1
- {simplepush-2.2.3 → simplepush-2.2.4}/src/simplepush/__init__.py +1 -1
- {simplepush-2.2.3 → simplepush-2.2.4}/src/simplepush/simplepush.py +18 -4
- {simplepush-2.2.3 → simplepush-2.2.4/src/simplepush.egg-info}/PKG-INFO +6 -2
- {simplepush-2.2.3 → simplepush-2.2.4}/LICENSE.txt +0 -0
- {simplepush-2.2.3 → simplepush-2.2.4}/README.md +0 -0
- {simplepush-2.2.3 → simplepush-2.2.4}/setup.cfg +0 -0
- {simplepush-2.2.3 → simplepush-2.2.4}/src/simplepush.egg-info/SOURCES.txt +0 -0
- {simplepush-2.2.3 → simplepush-2.2.4}/src/simplepush.egg-info/dependency_links.txt +0 -0
- {simplepush-2.2.3 → simplepush-2.2.4}/src/simplepush.egg-info/requires.txt +0 -0
- {simplepush-2.2.3 → simplepush-2.2.4}/src/simplepush.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: simplepush
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.4
|
|
4
4
|
Summary: Simplepush Python Library
|
|
5
5
|
Author-email: Timm Schaeuble <contact@simplepush.io>
|
|
6
6
|
Project-URL: Homepage, https://github.com/simplepush/simplepush-python
|
|
@@ -10,6 +10,10 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
10
10
|
Classifier: Operating System :: OS Independent
|
|
11
11
|
Description-Content-Type: text/markdown
|
|
12
12
|
License-File: LICENSE.txt
|
|
13
|
+
Requires-Dist: requests
|
|
14
|
+
Requires-Dist: cryptography
|
|
15
|
+
Requires-Dist: aiohttp
|
|
16
|
+
Dynamic: license-file
|
|
13
17
|
|
|
14
18
|
Python module to send push notifications via [Simplepush](https://simplepush.io/).
|
|
15
19
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
from .simplepush import send, async_send, BadRequest, UnknownError, FeedbackActionError, FeedbackActionTimeout, FeedbackUnavailable
|
|
1
|
+
from .simplepush import send, async_send, BadRequest, UnknownError, FeedbackActionError, FeedbackActionTimeout, FeedbackUnavailable, RateLimitExceeded
|
|
@@ -37,6 +37,10 @@ class FeedbackUnavailable(Exception):
|
|
|
37
37
|
"""Raised when feedback doesn't exist."""
|
|
38
38
|
pass
|
|
39
39
|
|
|
40
|
+
class RateLimitExceeded(Exception):
|
|
41
|
+
"""Raised when rate limit is exceeded."""
|
|
42
|
+
pass
|
|
43
|
+
|
|
40
44
|
|
|
41
45
|
def send(key, message, title=None, password=None, salt=None, attachments = None, event=None, actions=None, feedback_callback=None, feedback_callback_timeout=60, ignore_connection_errors=True):
|
|
42
46
|
"""Send a plain-text message."""
|
|
@@ -75,14 +79,19 @@ async def async_send(key, message, title=None, password=None, salt=None, attachm
|
|
|
75
79
|
|
|
76
80
|
if aiohttp_session:
|
|
77
81
|
async with aiohttp_session.post(SIMPLEPUSH_URL + '/send', json=payload) as resp:
|
|
78
|
-
return await _async_handle_response(
|
|
82
|
+
return await _async_handle_response(resp, actions, actions_encrypted, feedback_callback, feedback_callback_timeout,ignore_connection_errors, aiohttp_session)
|
|
79
83
|
else:
|
|
80
|
-
|
|
84
|
+
timeout = aiohttp.ClientTimeout(total=DEFAULT_TIMEOUT)
|
|
85
|
+
async with aiohttp.ClientSession(timeout=timeout) as session:
|
|
81
86
|
async with session.post(SIMPLEPUSH_URL + '/send', json=payload) as resp:
|
|
82
|
-
return await _async_handle_response(
|
|
87
|
+
return await _async_handle_response(resp, actions, actions_encrypted, feedback_callback, feedback_callback_timeout, ignore_connection_errors, session)
|
|
83
88
|
|
|
84
89
|
def _handle_response(response, actions, actions_encrypted, feedback_callback, feedback_callback_timeout, ignore_connection_errors):
|
|
85
90
|
"""Raise error if message was not successfully sent."""
|
|
91
|
+
|
|
92
|
+
if response.status_code == 429:
|
|
93
|
+
raise RateLimitExceeded
|
|
94
|
+
|
|
86
95
|
if response.json()['status'] == 'BadRequest' and response.json()['message'] == 'Title or message too long':
|
|
87
96
|
raise BadRequest
|
|
88
97
|
|
|
@@ -95,8 +104,13 @@ def _handle_response(response, actions, actions_encrypted, feedback_callback, fe
|
|
|
95
104
|
|
|
96
105
|
response.raise_for_status()
|
|
97
106
|
|
|
98
|
-
async def _async_handle_response(
|
|
107
|
+
async def _async_handle_response(response, actions, actions_encrypted, feedback_callback, feedback_callback_timeout, ignore_connection_errors, aiohttp_session):
|
|
99
108
|
"""Raise error if message was not successfully sent."""
|
|
109
|
+
|
|
110
|
+
if response.status == 429:
|
|
111
|
+
raise RateLimitExceeded
|
|
112
|
+
|
|
113
|
+
json_response = await response.json()
|
|
100
114
|
if json_response['status'] == 'BadRequest' and json_response['message'] == 'Title or message too long':
|
|
101
115
|
raise BadRequest
|
|
102
116
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: simplepush
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.4
|
|
4
4
|
Summary: Simplepush Python Library
|
|
5
5
|
Author-email: Timm Schaeuble <contact@simplepush.io>
|
|
6
6
|
Project-URL: Homepage, https://github.com/simplepush/simplepush-python
|
|
@@ -10,6 +10,10 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
10
10
|
Classifier: Operating System :: OS Independent
|
|
11
11
|
Description-Content-Type: text/markdown
|
|
12
12
|
License-File: LICENSE.txt
|
|
13
|
+
Requires-Dist: requests
|
|
14
|
+
Requires-Dist: cryptography
|
|
15
|
+
Requires-Dist: aiohttp
|
|
16
|
+
Dynamic: license-file
|
|
13
17
|
|
|
14
18
|
Python module to send push notifications via [Simplepush](https://simplepush.io/).
|
|
15
19
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|