1 """Utilities for the Huawei LTE integration."""
3 from __future__
import annotations
5 from contextlib
import suppress
7 from urllib.parse
import urlparse
10 from huawei_lte_api.Session
import GetResponseType
12 from urllib3.exceptions
import InsecureRequestWarning
18 device_info: GetResponseType, wlan_settings: GetResponseType
20 """Get list of device MAC addresses.
22 :param device_info: the device.information structure for the device
23 :param wlan_settings: the wlan.multi_basic_settings structure for the device
27 for x
in (
"MacAddress1",
"MacAddress2",
"WifiMacAddrWl0",
"WifiMacAddrWl1")
30 with suppress(Exception):
31 macs.extend(x.get(
"WifiMac")
for x
in wlan_settings[
"Ssids"][
"Ssid"])
37 """Get requests.Session that does not verify HTTPS, filter warnings about it."""
38 parsed_url = urlparse(url)
39 assert parsed_url.hostname
40 requests_session = requests.Session()
41 requests_session.verify =
False
42 warnings.filterwarnings(
44 message=rf
"^.*\b{re.escape(parsed_url.hostname)}\b",
45 category=InsecureRequestWarning,
46 module=
r"^urllib3\.connectionpool$",
48 return requests_session
requests.Session non_verifying_requests_session(str url)
list[str] get_device_macs(GetResponseType device_info, GetResponseType wlan_settings)