mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +00:00
Add camera timeouts
This commit is contained in:
parent
2508e9f9ff
commit
a80a74b586
@ -49,7 +49,7 @@ 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
|
||||||
response = requests.get(self._snap_picture_url)
|
response = requests.get(self._snap_picture_url, timeout=10)
|
||||||
|
|
||||||
return response.content
|
return response.content
|
||||||
|
|
||||||
|
@ -43,13 +43,14 @@ class GenericCamera(Camera):
|
|||||||
try:
|
try:
|
||||||
response = requests.get(
|
response = requests.get(
|
||||||
self._still_image_url,
|
self._still_image_url,
|
||||||
auth=HTTPBasicAuth(self._username, self._password))
|
auth=HTTPBasicAuth(self._username, self._password),
|
||||||
|
timeout=10)
|
||||||
except requests.exceptions.RequestException as error:
|
except requests.exceptions.RequestException as error:
|
||||||
_LOGGER.error('Error getting camera image: %s', error)
|
_LOGGER.error('Error getting camera image: %s', error)
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
response = requests.get(self._still_image_url)
|
response = requests.get(self._still_image_url, timeout=10)
|
||||||
except requests.exceptions.RequestException as error:
|
except requests.exceptions.RequestException as error:
|
||||||
_LOGGER.error('Error getting camera image: %s', error)
|
_LOGGER.error('Error getting camera image: %s', error)
|
||||||
return None
|
return None
|
||||||
|
@ -57,10 +57,10 @@ class WelcomeCamera(Camera):
|
|||||||
try:
|
try:
|
||||||
if self._localurl:
|
if self._localurl:
|
||||||
response = requests.get('{0}/live/snapshot_720.jpg'.format(
|
response = requests.get('{0}/live/snapshot_720.jpg'.format(
|
||||||
self._localurl))
|
self._localurl), timeout=10)
|
||||||
else:
|
else:
|
||||||
response = requests.get('{0}/live/snapshot_720.jpg'.format(
|
response = requests.get('{0}/live/snapshot_720.jpg'.format(
|
||||||
self._vpnurl))
|
self._vpnurl), timeout=10)
|
||||||
except requests.exceptions.RequestException as error:
|
except requests.exceptions.RequestException as error:
|
||||||
_LOGGER.error('Welcome VPN url changed: %s', error)
|
_LOGGER.error('Welcome VPN url changed: %s', error)
|
||||||
self._data.update()
|
self._data.update()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user