mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 16:57:10 +00:00
Foscam Camera: Adding exception handling when fetching the camera image to avoid python exception errors when host is not reachable or rather any url error to camera (#6964)
* Adding exception handling when fetching the camera image to avoid python errors when host is not reachable or any url errors to camera * Added exception as ConnectionError instead of plain except * Added exception as ConnectionError instead of plain except. Removed the unused error handle
This commit is contained in:
parent
f96e06a2c2
commit
9254e7e862
@ -66,8 +66,12 @@ class FoscamCamera(Camera):
|
|||||||
def camera_image(self):
|
def camera_image(self):
|
||||||
"""Return a still image reponse from the camera."""
|
"""Return a still image reponse from the camera."""
|
||||||
# Send the request to snap a picture and return raw jpg data
|
# Send the request to snap a picture and return raw jpg data
|
||||||
|
# Handle exception if host is not reachable or url failed
|
||||||
|
try:
|
||||||
response = requests.get(self._snap_picture_url, timeout=10)
|
response = requests.get(self._snap_picture_url, timeout=10)
|
||||||
|
except requests.exceptions.ConnectionError:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
return response.content
|
return response.content
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
x
Reference in New Issue
Block a user