Bump amcrest to 1.2.6 & use new exceptions (#22040)

* Bump amcrest to 1.2.6 & use new exceptions

* Fix lint failure

* Use AmcrestError instead of individual ones
This commit is contained in:
Phil Bruckner authored and Paulus Schoutsen committed 2019-03-14 10:56:33 -07:00
1 parent 4e84e8a15e
commit 8d2d71c16a
3 files changed
+9 -10

No files matched your search

+4 -4
View File
@@ -2,9 +2,6 @@
import asyncio
import logging
from requests import RequestException
from urllib3.exceptions import ReadTimeoutError
from homeassistant.components.amcrest import (
DATA_AMCREST, STREAM_SOURCE_LIST, TIMEOUT)
from homeassistant.components.camera import Camera
@@ -14,6 +11,7 @@ from homeassistant.helpers.aiohttp_client import (
async_get_clientsession, async_aiohttp_proxy_web,
async_aiohttp_proxy_stream)
DEPENDENCIES = ['amcrest', 'ffmpeg']
_LOGGER = logging.getLogger(__name__)
@@ -51,13 +49,15 @@ class AmcrestCam(Camera):
async def async_camera_image(self):
"""Return a still image response from the camera."""
from amcrest import AmcrestError
async with self._snapshot_lock:
try:
# Send the request to snap a picture and return raw jpg data
response = await self.hass.async_add_executor_job(
self._camera.snapshot, self._resolution)
return response.data
except (RequestException, ReadTimeoutError, ValueError) as error:
except AmcrestError as error:
_LOGGER.error(
'Could not get camera image due to error %s', error)
return None