From 92a38e9fbe8ea1c39bd79cbdea9e0417c1cbe625 Mon Sep 17 00:00:00 2001 From: mrlt8 <67088095+mrlt8@users.noreply.github.com> Date: Tue, 1 Oct 2024 20:14:28 -0700 Subject: [PATCH] Add additional error logging #1355 --- app/wyzebridge/onvif.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/wyzebridge/onvif.py b/app/wyzebridge/onvif.py index a6eb09a2..3a794754 100644 --- a/app/wyzebridge/onvif.py +++ b/app/wyzebridge/onvif.py @@ -108,15 +108,14 @@ def parse_request(xml_request): try: root = ElementTree.fromstring(xml_request) creds = None - if auth := root.find(".//wsse:UsernameToken", NAMESPACES): + if (auth := root.find(".//wsse:UsernameToken", NAMESPACES)) is not None: creds = { "username": auth.findtext(".//wsse:Username", None, NAMESPACES), "password": auth.findtext(".//wsse:Password", None, NAMESPACES), "nonce": auth.findtext(".//wsse:Nonce", None, NAMESPACES), "created": auth.findtext(".//wsu:Created", None, NAMESPACES), } - - if (body := root.find(".//s:Body", NAMESPACES)) and len(body) > 0: + if (body := root.find(".//s:Body", NAMESPACES)) is not None: action = body[0].tag.rsplit("}", 1)[-1] profile = body[0].findtext(".//wsdl:ProfileToken", None, NAMESPACES) logger.debug(f"[ONVIF] XML request: {action=}, {profile=}") @@ -166,7 +165,7 @@ def service_resp(streams): resp = unknown_request() if not WbAuth.auth_onvif(creds): - logger.error("Onvif auth failed") + logger.error(f"[ONVIF] Auth failed for {action=} with {creds=}") resp = unauthorized() return f"""