Skip to content

Commit

Permalink
Adjust
Browse files Browse the repository at this point in the history
  • Loading branch information
epenet committed Sep 6, 2024
1 parent 8055299 commit ff73698
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/sfrbox_api/bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,15 @@ async def _get_token(self) -> str:
if not (self._username and self._password):
raise SFRBoxAuthenticationError("Credentials not set")
element = await self._send_get("auth", "getToken")
if TYPE_CHECKING:
assert element is not None
assert element is not None # noqa: S101
if (method := element.get("method")) not in {"all", "passwd"}:
raise SFRBoxAuthenticationError(
f"Password authentication is not allowed, valid methods: `{method}`"
)
token = element.get("token", "")
hash = compute_hash(token, self._username, self._password)
element = await self._send_get("auth", "checkToken", token=token, hash=hash)
if TYPE_CHECKING:
assert element is not None
assert element is not None # noqa: S101
return element.get("token", "")

def _check_response(self, response: httpx.Response) -> XmlElement:
Expand Down Expand Up @@ -225,11 +223,9 @@ async def wlan_get_info(self) -> WlanInfo:
"""Renvoie les informations sur le WiFi."""
token = await self._ensure_token()
xml_response = await self._send_get("wlan", "getInfo", token=token)
if TYPE_CHECKING:
assert xml_response is not None
assert xml_response is not None # noqa: S101
wl0_element = xml_response.find("wl0")
if TYPE_CHECKING:
assert wl0_element is not None
assert wl0_element is not None # noqa: S101
wl0 = WlanWl0Info(**wl0_element.attrib)
return WlanInfo(**xml_response.attrib, wl0=wl0)

Expand Down

0 comments on commit ff73698

Please sign in to comment.