Take Huawei LTE XML parse errors to mean unsupported endpoint (#72781)

This commit is contained in:
Ville Skyttä 2022-06-29 00:13:26 +03:00 committed by GitHub
parent efbd47c828
commit 1a55c7db34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,6 +9,7 @@ from datetime import timedelta
import logging
import time
from typing import Any, NamedTuple, cast
from xml.parsers.expat import ExpatError
from huawei_lte_api.Client import Client
from huawei_lte_api.Connection import Connection
@ -204,14 +205,13 @@ class Router:
"%s requires authorization, excluding from future updates", key
)
self.subscriptions.pop(key)
except ResponseErrorException as exc:
except (ResponseErrorException, ExpatError) as exc:
# Take ResponseErrorNotSupportedException, ExpatError, and generic
# ResponseErrorException with a few select codes to mean the endpoint is
# not supported.
if not isinstance(
exc, ResponseErrorNotSupportedException
) and exc.code not in (
# additional codes treated as unusupported
-1,
100006,
):
exc, (ResponseErrorNotSupportedException, ExpatError)
) and exc.code not in (-1, 100006):
raise
_LOGGER.info(
"%s apparently not supported by device, excluding from future updates",