uiprotect 2.2.0__py3-none-any.whl → 2.3.0__py3-none-any.whl

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/websocket.py CHANGED
@@ -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]]
@@ -79,7 +81,7 @@ class Websocket:
79
81
  _LOGGER.log(
80
82
  level, "Websocket authentication error: %s: %s", url, ex
81
83
  )
82
- await self._attempt_reauth()
84
+ await self._attempt_auth(True)
83
85
  else:
84
86
  _LOGGER.log(level, "Websocket handshake error: %s: %s", url, ex)
85
87
  else:
@@ -97,7 +99,7 @@ class Websocket:
97
99
 
98
100
  async def _websocket_inner_loop(self, url: URL) -> None:
99
101
  _LOGGER.debug("Connecting WS to %s", url)
100
- self._headers = await self._auth(False)
102
+ await self._attempt_auth(False)
101
103
  ssl = None if self.verify else False
102
104
  msg: WSMessage | None = None
103
105
  self._seen_non_close_message = False
@@ -140,12 +142,14 @@ class Websocket:
140
142
  await self._ws_connection.close()
141
143
  self._ws_connection = None
142
144
 
143
- async def _attempt_reauth(self) -> None:
144
- """Attempt to re-authenticate."""
145
+ async def _attempt_auth(self, force: bool) -> None:
146
+ """Attempt to authenticate."""
145
147
  try:
146
- self._headers = await self._auth(True)
148
+ self._headers = await self._auth(force)
149
+ except (NotAuthorized, NvrError) as ex:
150
+ _LOGGER.debug("Error authenticating websocket: %s", ex)
147
151
  except Exception:
148
- _LOGGER.exception("Error reauthenticating websocket")
152
+ _LOGGER.exception("Unknown error authenticating websocket")
149
153
 
150
154
  def start(self) -> None:
151
155
  """Start the websocket."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: uiprotect
3
- Version: 2.2.0
3
+ Version: 2.3.0
4
4
  Summary: Python API for Unifi Protect (Unofficial)
5
5
  Home-page: https://github.com/uilibs/uiprotect
6
6
  License: MIT
@@ -29,9 +29,9 @@ uiprotect/stream.py,sha256=McV3XymKyjn-1uV5jdQHcpaDjqLS4zWyMASQ8ubcyb4,4924
29
29
  uiprotect/test_util/__init__.py,sha256=whiOUb5LfDLNT3AQG6ISiKtAqO2JnhCIdFavhWDK46M,18718
30
30
  uiprotect/test_util/anonymize.py,sha256=f-8ijU-_y9r-uAbhIPn0f0I6hzJpAkvJzc8UpWihObI,8478
31
31
  uiprotect/utils.py,sha256=3SJFF8qs1Jz8t3mD8qwc1hFSocolFjdXI_v4yVlC7o4,20088
32
- uiprotect/websocket.py,sha256=Ufm1WLOeKCffXvSl8pWT11Q_t8tNpGHZWgeAL7Ao4mc,6799
33
- uiprotect-2.2.0.dist-info/LICENSE,sha256=INx18jhdbVXMEiiBANeKEbrbz57ckgzxk5uutmmcxGk,1111
34
- uiprotect-2.2.0.dist-info/METADATA,sha256=8TmCakZrF5cw4pKa7xLQzt-fyQFDMDKp1iCl4zUNl04,10982
35
- uiprotect-2.2.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
36
- uiprotect-2.2.0.dist-info/entry_points.txt,sha256=J78AUTPrTTxgI3s7SVgrmGqDP7piX2wuuEORzhDdVRA,47
37
- uiprotect-2.2.0.dist-info/RECORD,,
32
+ uiprotect/websocket.py,sha256=wWcVhMST_hFamOIUQogUytMqwpsvKwKN73BYErYTrJU,6973
33
+ uiprotect-2.3.0.dist-info/LICENSE,sha256=INx18jhdbVXMEiiBANeKEbrbz57ckgzxk5uutmmcxGk,1111
34
+ uiprotect-2.3.0.dist-info/METADATA,sha256=xDsK9L2Z2AUNMES1nvIPYIuPJO6mrGzvgL45540h3Zs,10982
35
+ uiprotect-2.3.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
36
+ uiprotect-2.3.0.dist-info/entry_points.txt,sha256=J78AUTPrTTxgI3s7SVgrmGqDP7piX2wuuEORzhDdVRA,47
37
+ uiprotect-2.3.0.dist-info/RECORD,,