uiprotect 2.1.0__tar.gz → 2.3.0__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.
Potentially problematic release.
This version of uiprotect might be problematic. Click here for more details.
- {uiprotect-2.1.0 → uiprotect-2.3.0}/PKG-INFO +1 -1
- {uiprotect-2.1.0 → uiprotect-2.3.0}/pyproject.toml +1 -1
- {uiprotect-2.1.0 → uiprotect-2.3.0}/src/uiprotect/websocket.py +16 -17
- {uiprotect-2.1.0 → uiprotect-2.3.0}/LICENSE +0 -0
- {uiprotect-2.1.0 → uiprotect-2.3.0}/README.md +0 -0
- {uiprotect-2.1.0 → uiprotect-2.3.0}/src/uiprotect/__init__.py +0 -0
- {uiprotect-2.1.0 → uiprotect-2.3.0}/src/uiprotect/__main__.py +0 -0
- {uiprotect-2.1.0 → uiprotect-2.3.0}/src/uiprotect/api.py +0 -0
- {uiprotect-2.1.0 → uiprotect-2.3.0}/src/uiprotect/cli/__init__.py +0 -0
- {uiprotect-2.1.0 → uiprotect-2.3.0}/src/uiprotect/cli/backup.py +0 -0
- {uiprotect-2.1.0 → uiprotect-2.3.0}/src/uiprotect/cli/base.py +0 -0
- {uiprotect-2.1.0 → uiprotect-2.3.0}/src/uiprotect/cli/cameras.py +0 -0
- {uiprotect-2.1.0 → uiprotect-2.3.0}/src/uiprotect/cli/chimes.py +0 -0
- {uiprotect-2.1.0 → uiprotect-2.3.0}/src/uiprotect/cli/doorlocks.py +0 -0
- {uiprotect-2.1.0 → uiprotect-2.3.0}/src/uiprotect/cli/events.py +0 -0
- {uiprotect-2.1.0 → uiprotect-2.3.0}/src/uiprotect/cli/lights.py +0 -0
- {uiprotect-2.1.0 → uiprotect-2.3.0}/src/uiprotect/cli/liveviews.py +0 -0
- {uiprotect-2.1.0 → uiprotect-2.3.0}/src/uiprotect/cli/nvr.py +0 -0
- {uiprotect-2.1.0 → uiprotect-2.3.0}/src/uiprotect/cli/sensors.py +0 -0
- {uiprotect-2.1.0 → uiprotect-2.3.0}/src/uiprotect/cli/viewers.py +0 -0
- {uiprotect-2.1.0 → uiprotect-2.3.0}/src/uiprotect/data/__init__.py +0 -0
- {uiprotect-2.1.0 → uiprotect-2.3.0}/src/uiprotect/data/base.py +0 -0
- {uiprotect-2.1.0 → uiprotect-2.3.0}/src/uiprotect/data/bootstrap.py +0 -0
- {uiprotect-2.1.0 → uiprotect-2.3.0}/src/uiprotect/data/convert.py +0 -0
- {uiprotect-2.1.0 → uiprotect-2.3.0}/src/uiprotect/data/devices.py +0 -0
- {uiprotect-2.1.0 → uiprotect-2.3.0}/src/uiprotect/data/nvr.py +0 -0
- {uiprotect-2.1.0 → uiprotect-2.3.0}/src/uiprotect/data/types.py +0 -0
- {uiprotect-2.1.0 → uiprotect-2.3.0}/src/uiprotect/data/user.py +0 -0
- {uiprotect-2.1.0 → uiprotect-2.3.0}/src/uiprotect/data/websocket.py +0 -0
- {uiprotect-2.1.0 → uiprotect-2.3.0}/src/uiprotect/exceptions.py +0 -0
- {uiprotect-2.1.0 → uiprotect-2.3.0}/src/uiprotect/py.typed +0 -0
- {uiprotect-2.1.0 → uiprotect-2.3.0}/src/uiprotect/release_cache.json +0 -0
- {uiprotect-2.1.0 → uiprotect-2.3.0}/src/uiprotect/stream.py +0 -0
- {uiprotect-2.1.0 → uiprotect-2.3.0}/src/uiprotect/test_util/__init__.py +0 -0
- {uiprotect-2.1.0 → uiprotect-2.3.0}/src/uiprotect/test_util/anonymize.py +0 -0
- {uiprotect-2.1.0 → uiprotect-2.3.0}/src/uiprotect/utils.py +0 -0
|
@@ -19,6 +19,8 @@ from aiohttp import (
|
|
|
19
19
|
)
|
|
20
20
|
from yarl import URL
|
|
21
21
|
|
|
22
|
+
from .exceptions import NotAuthorized, NvrError
|
|
23
|
+
|
|
22
24
|
_LOGGER = logging.getLogger(__name__)
|
|
23
25
|
AuthCallbackType = Callable[..., Coroutine[Any, Any, Optional[dict[str, str]]]]
|
|
24
26
|
GetSessionCallbackType = Callable[[], Awaitable[ClientSession]]
|
|
@@ -76,33 +78,28 @@ class Websocket:
|
|
|
76
78
|
level = logging.ERROR if self._seen_non_close_message else logging.DEBUG
|
|
77
79
|
if isinstance(ex, WSServerHandshakeError):
|
|
78
80
|
if ex.status == HTTPStatus.UNAUTHORIZED.value:
|
|
79
|
-
_LOGGER.log(level, "Websocket authentication error: %s", url)
|
|
80
|
-
await self._attempt_reauth()
|
|
81
|
-
else:
|
|
82
81
|
_LOGGER.log(
|
|
83
|
-
level, "Websocket
|
|
82
|
+
level, "Websocket authentication error: %s: %s", url, ex
|
|
84
83
|
)
|
|
84
|
+
await self._attempt_auth(True)
|
|
85
|
+
else:
|
|
86
|
+
_LOGGER.log(level, "Websocket handshake error: %s: %s", url, ex)
|
|
85
87
|
else:
|
|
86
|
-
_LOGGER.log(
|
|
87
|
-
level, "Websocket disconnect error: %s", url, exc_info=True
|
|
88
|
-
)
|
|
88
|
+
_LOGGER.log(level, "Websocket disconnect error: %s: %s", url, ex)
|
|
89
89
|
except asyncio.TimeoutError:
|
|
90
90
|
level = logging.ERROR if self._seen_non_close_message else logging.DEBUG
|
|
91
91
|
_LOGGER.log(level, "Websocket timeout: %s", url)
|
|
92
92
|
except Exception:
|
|
93
|
-
_LOGGER.
|
|
94
|
-
"Unexpected error in websocket reconnect loop, backoff: %s",
|
|
95
|
-
backoff,
|
|
96
|
-
exc_info=True,
|
|
97
|
-
)
|
|
93
|
+
_LOGGER.exception("Unexpected error in websocket loop")
|
|
98
94
|
|
|
99
95
|
if self._running is False:
|
|
100
96
|
break
|
|
97
|
+
_LOGGER.debug("Reconnecting websocket in %s seconds", backoff)
|
|
101
98
|
await asyncio.sleep(self.backoff)
|
|
102
99
|
|
|
103
100
|
async def _websocket_inner_loop(self, url: URL) -> None:
|
|
104
101
|
_LOGGER.debug("Connecting WS to %s", url)
|
|
105
|
-
|
|
102
|
+
await self._attempt_auth(False)
|
|
106
103
|
ssl = None if self.verify else False
|
|
107
104
|
msg: WSMessage | None = None
|
|
108
105
|
self._seen_non_close_message = False
|
|
@@ -145,12 +142,14 @@ class Websocket:
|
|
|
145
142
|
await self._ws_connection.close()
|
|
146
143
|
self._ws_connection = None
|
|
147
144
|
|
|
148
|
-
async def
|
|
149
|
-
"""Attempt to
|
|
145
|
+
async def _attempt_auth(self, force: bool) -> None:
|
|
146
|
+
"""Attempt to authenticate."""
|
|
150
147
|
try:
|
|
151
|
-
self._headers = await self._auth(
|
|
148
|
+
self._headers = await self._auth(force)
|
|
149
|
+
except (NotAuthorized, NvrError) as ex:
|
|
150
|
+
_LOGGER.debug("Error authenticating websocket: %s", ex)
|
|
152
151
|
except Exception:
|
|
153
|
-
_LOGGER.exception("
|
|
152
|
+
_LOGGER.exception("Unknown error authenticating websocket")
|
|
154
153
|
|
|
155
154
|
def start(self) -> None:
|
|
156
155
|
"""Start the websocket."""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|