python-ntfy 0.10.5__tar.gz → 0.11.1__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.
- {python_ntfy-0.10.5 → python_ntfy-0.11.1}/PKG-INFO +1 -1
- {python_ntfy-0.10.5 → python_ntfy-0.11.1}/pyproject.toml +1 -11
- {python_ntfy-0.10.5 → python_ntfy-0.11.1}/python_ntfy/_exceptions.py +10 -2
- {python_ntfy-0.10.5 → python_ntfy-0.11.1}/python_ntfy/_get_functions.py +14 -7
- {python_ntfy-0.10.5 → python_ntfy-0.11.1}/README.md +0 -0
- {python_ntfy-0.10.5 → python_ntfy-0.11.1}/python_ntfy/__init__.py +0 -0
- {python_ntfy-0.10.5 → python_ntfy-0.11.1}/python_ntfy/_ntfy.py +0 -0
- {python_ntfy-0.10.5 → python_ntfy-0.11.1}/python_ntfy/_send_functions.py +0 -0
- {python_ntfy-0.10.5 → python_ntfy-0.11.1}/python_ntfy/client.py +0 -0
- {python_ntfy-0.10.5 → python_ntfy-0.11.1}/python_ntfy/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "python-ntfy"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.11.1"
|
|
4
4
|
description = "An easy-to-use library for the ntfy notification service."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "MIT"
|
|
@@ -130,13 +130,3 @@ disallow_untyped_defs = true
|
|
|
130
130
|
[tool.ty.environment]
|
|
131
131
|
root = ["."]
|
|
132
132
|
python = "./.venv"
|
|
133
|
-
|
|
134
|
-
[tool.uv-secure.vulnerability_criteria]
|
|
135
|
-
show_severity = true
|
|
136
|
-
ignore_unfixed = true
|
|
137
|
-
|
|
138
|
-
[tool.uv-secure.maintainability_criteria]
|
|
139
|
-
forbid_yanked = true
|
|
140
|
-
forbid_archived = true
|
|
141
|
-
forbid_deprecated = true
|
|
142
|
-
forbid_quarantined = true
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
class
|
|
2
|
-
"""
|
|
1
|
+
class NtfyMessageError(Exception):
|
|
2
|
+
"""Base exception for ntfy message errors."""
|
|
3
3
|
|
|
4
4
|
def __init__(self, message: str) -> None:
|
|
5
5
|
"""Initialize the exception.
|
|
@@ -9,3 +9,11 @@ class MessageSendError(Exception):
|
|
|
9
9
|
"""
|
|
10
10
|
self.message = message
|
|
11
11
|
super().__init__(self.message)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class MessageSendError(NtfyMessageError):
|
|
15
|
+
"""Exception raised when a message fails to send."""
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class MessageReceiveError(NtfyMessageError):
|
|
19
|
+
"""Exception raised when a message fails to retrieved."""
|
|
@@ -2,6 +2,8 @@ import json
|
|
|
2
2
|
|
|
3
3
|
import requests
|
|
4
4
|
|
|
5
|
+
from python_ntfy._exceptions import MessageReceiveError
|
|
6
|
+
|
|
5
7
|
|
|
6
8
|
def get_cached_messages(
|
|
7
9
|
self,
|
|
@@ -19,6 +21,9 @@ def get_cached_messages(
|
|
|
19
21
|
Returns:
|
|
20
22
|
A list of messages.
|
|
21
23
|
|
|
24
|
+
Raises:
|
|
25
|
+
MessageReceiveError: If the request fails or the response is invalid.
|
|
26
|
+
|
|
22
27
|
Examples:
|
|
23
28
|
>>> response = client.get(since="all")
|
|
24
29
|
|
|
@@ -34,16 +39,18 @@ def get_cached_messages(
|
|
|
34
39
|
if since:
|
|
35
40
|
params.update({"since": since})
|
|
36
41
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
for line in requests.get(
|
|
42
|
+
try:
|
|
43
|
+
response = requests.get(
|
|
40
44
|
url=self.url + "/json",
|
|
41
45
|
params=params,
|
|
42
46
|
auth=self._auth,
|
|
43
47
|
timeout=timeout_seconds,
|
|
44
48
|
)
|
|
45
|
-
.
|
|
46
|
-
.splitlines()
|
|
47
|
-
|
|
49
|
+
response.raise_for_status()
|
|
50
|
+
messages = [json.loads(line) for line in response.text.strip().splitlines()]
|
|
51
|
+
except requests.exceptions.RequestException as e:
|
|
52
|
+
error_message = f"Failed to receive messages: {e}"
|
|
53
|
+
raise MessageReceiveError(error_message) from e
|
|
54
|
+
|
|
48
55
|
# Reverse the list so that the most recent notification is first
|
|
49
|
-
return sorted(
|
|
56
|
+
return sorted(messages, key=lambda x: x["time"], reverse=True)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|