simplepush 2.2.2__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.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: simplepush
3
- Version: 2.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,15 +1,10 @@
1
1
  [build-system]
2
- requires = [
3
- "setuptools>=61.0",
4
- "requests",
5
- "cryptography",
6
- "aiohttp"
7
- ]
2
+ requires = ["setuptools>=61.0"]
8
3
  build-backend = "setuptools.build_meta"
9
4
 
10
5
  [project]
11
6
  name = "simplepush"
12
- version = "2.2.2"
7
+ version = "2.2.4"
13
8
  authors = [
14
9
  { name="Timm Schaeuble", email="contact@simplepush.io" },
15
10
  ]
@@ -20,6 +15,11 @@ classifiers = [
20
15
  "License :: OSI Approved :: MIT License",
21
16
  "Operating System :: OS Independent",
22
17
  ]
18
+ dependencies = [
19
+ "requests",
20
+ "cryptography",
21
+ "aiohttp"
22
+ ]
23
23
 
24
24
  [project.urls]
25
25
  "Homepage" = "https://github.com/simplepush/simplepush-python"
@@ -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(await resp.json(), actions, actions_encrypted, feedback_callback, feedback_callback_timeout,ignore_connection_errors, aiohttp_session)
82
+ return await _async_handle_response(resp, actions, actions_encrypted, feedback_callback, feedback_callback_timeout,ignore_connection_errors, aiohttp_session)
79
83
  else:
80
- async with aiohttp.ClientSession(raise_for_status=True) as session:
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(await resp.json(), actions, actions_encrypted, feedback_callback, feedback_callback_timeout, ignore_connection_errors, session)
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(json_response, actions, actions_encrypted, feedback_callback, feedback_callback_timeout, ignore_connection_errors, aiohttp_session):
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
1
+ Metadata-Version: 2.4
2
2
  Name: simplepush
3
- Version: 2.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
 
@@ -6,4 +6,5 @@ src/simplepush/simplepush.py
6
6
  src/simplepush.egg-info/PKG-INFO
7
7
  src/simplepush.egg-info/SOURCES.txt
8
8
  src/simplepush.egg-info/dependency_links.txt
9
+ src/simplepush.egg-info/requires.txt
9
10
  src/simplepush.egg-info/top_level.txt
@@ -0,0 +1,3 @@
1
+ requests
2
+ cryptography
3
+ aiohttp
File without changes
File without changes
File without changes