diff --git a/huawei_lte_api/api/User.py b/huawei_lte_api/api/User.py index 8418f91..b66590e 100644 --- a/huawei_lte_api/api/User.py +++ b/huawei_lte_api/api/User.py @@ -16,6 +16,7 @@ LoginErrorUsernamePasswordWrongException, \ LoginErrorUsernameWrongException, \ LoginErrorPasswordWrongException, \ + ResponseErrorLoginRequiredException, \ ResponseErrorNotSupportedException DEFAULT_USERNAME = 'admin' @@ -27,7 +28,11 @@ def __init__(self, session: Session, username: str = DEFAULT_USERNAME, password: self.user.login(username, password, True) def close(self) -> None: - self.user.logout() + try: + self.user.logout() + except (ResponseErrorLoginRequiredException, ResponseErrorNotSupportedException): + # Idempotency/nothing further to do, suppress + pass def __enter__(self) -> 'UserSession': return self