Skip to content

Commit 76ea5e7

Browse files
authored
Handle Fault when fetching GetSnapshotUri (#50)
1 parent f931157 commit 76ea5e7

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

onvif/client.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -506,14 +506,23 @@ async def get_snapshot_uri(self, profile_token: str) -> str:
506506
media_service = await self.create_media_service()
507507
req = media_service.create_type("GetSnapshotUri")
508508
req.ProfileToken = profile_token
509-
result = await media_service.GetSnapshotUri(req)
509+
uri = None
510510
try:
511-
uri = normalize_url(result.Uri)
512-
except KeyError:
511+
result = await media_service.GetSnapshotUri(req)
512+
except zeep.exceptions.Fault as error:
513513
logger.warning(
514-
"%s: The device returned an invalid snapshot URI", self.host
514+
"%s: Failed to get snapshot URI for profile %s: %s",
515+
self.host,
516+
profile_token,
517+
error,
515518
)
516-
uri = None
519+
else:
520+
try:
521+
uri = normalize_url(result.Uri)
522+
except KeyError:
523+
logger.warning(
524+
"%s: The device returned an invalid snapshot URI", self.host
525+
)
517526
self._snapshot_uris[profile_token] = uri
518527
return uri
519528

0 commit comments

Comments
 (0)