socketry 0.2.1__tar.gz → 0.2.2__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
1
  Metadata-Version: 2.4
2
2
  Name: socketry
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: Python API and CLI for controlling Jackery portable power stations
5
5
  Author: Jesus Lopez
6
6
  Author-email: Jesus Lopez <jesus@jesusla.com>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "socketry"
3
- version = "0.2.1"
3
+ version = "0.2.2"
4
4
  description = "Python API and CLI for controlling Jackery portable power stations"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -1,6 +1,13 @@
1
1
  """Python API and CLI for controlling Jackery portable power stations."""
2
2
 
3
- from socketry.client import AuthenticationError, Client, Device, MqttError, Subscription
3
+ from socketry.client import (
4
+ AuthenticationError,
5
+ Client,
6
+ Device,
7
+ MqttError,
8
+ SocketryError,
9
+ Subscription,
10
+ )
4
11
  from socketry.properties import MODEL_NAMES, PROPERTIES, Setting
5
12
 
6
13
  __all__ = [
@@ -11,5 +18,6 @@ __all__ = [
11
18
  "MqttError",
12
19
  "PROPERTIES",
13
20
  "Setting",
21
+ "SocketryError",
14
22
  "Subscription",
15
23
  ]
@@ -55,11 +55,15 @@ from socketry.properties import Setting, resolve
55
55
  _TOKEN_EXPIRY_BUFFER = 3600 # seconds before expiry to trigger proactive refresh
56
56
 
57
57
 
58
- class TokenExpiredError(RuntimeError):
58
+ class SocketryError(Exception):
59
+ """Base exception for all socketry errors."""
60
+
61
+
62
+ class TokenExpiredError(SocketryError):
59
63
  """Raised when the Jackery API returns error code 10402 (token expired)."""
60
64
 
61
65
 
62
- class AuthenticationError(Exception):
66
+ class AuthenticationError(SocketryError):
63
67
  """Raised when login fails after an automatic re-authentication attempt.
64
68
 
65
69
  Triggered when the Jackery API returns an auth error (session invalidated
@@ -68,7 +72,7 @@ class AuthenticationError(Exception):
68
72
  """
69
73
 
70
74
 
71
- class _SessionInvalidatedError(RuntimeError):
75
+ class _SessionInvalidatedError(SocketryError):
72
76
  """Internal sentinel: API returned a non-token-expiry auth/API error.
73
77
 
74
78
  Raised by HTTP helpers to signal that the current session is rejected by
@@ -77,7 +81,7 @@ class _SessionInvalidatedError(RuntimeError):
77
81
  """
78
82
 
79
83
 
80
- class MqttError(ConnectionError):
84
+ class MqttError(SocketryError, ConnectionError):
81
85
  """Raised when an MQTT operation fails.
82
86
 
83
87
  Wraps :class:`aiomqtt.MqttError` so callers do not need to import
@@ -854,7 +858,7 @@ async def _http_login(
854
858
 
855
859
  if body.get("code") != 0:
856
860
  msg = body.get("msg", "unknown error")
857
- raise RuntimeError(f"Login failed: {msg}")
861
+ raise AuthenticationError(f"Login failed: {msg}")
858
862
 
859
863
  data = body["data"]
860
864
  token = body["token"]
File without changes
File without changes
File without changes