mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 16:57:10 +00:00
MJPEG Camera Log Filter Fixes (#17050)
* Move filter to setup platform * pylint
This commit is contained in:
parent
90f71261c5
commit
0954eefa9f
@ -44,6 +44,14 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
|||||||
async def async_setup_platform(hass, config, async_add_entities,
|
async def async_setup_platform(hass, config, async_add_entities,
|
||||||
discovery_info=None):
|
discovery_info=None):
|
||||||
"""Set up a MJPEG IP Camera."""
|
"""Set up a MJPEG IP Camera."""
|
||||||
|
# Filter header errors from urllib3 due to a urllib3 bug
|
||||||
|
urllib3_logger = logging.getLogger("urllib3.connectionpool")
|
||||||
|
if not any(isinstance(x, NoHeaderErrorFilter)
|
||||||
|
for x in urllib3_logger.filters):
|
||||||
|
urllib3_logger.addFilter(
|
||||||
|
NoHeaderErrorFilter()
|
||||||
|
)
|
||||||
|
|
||||||
if discovery_info:
|
if discovery_info:
|
||||||
config = PLATFORM_SCHEMA(discovery_info)
|
config = PLATFORM_SCHEMA(discovery_info)
|
||||||
async_add_entities([MjpegCamera(config)])
|
async_add_entities([MjpegCamera(config)])
|
||||||
@ -74,10 +82,6 @@ class MjpegCamera(Camera):
|
|||||||
self._mjpeg_url = device_info[CONF_MJPEG_URL]
|
self._mjpeg_url = device_info[CONF_MJPEG_URL]
|
||||||
self._still_image_url = device_info.get(CONF_STILL_IMAGE_URL)
|
self._still_image_url = device_info.get(CONF_STILL_IMAGE_URL)
|
||||||
|
|
||||||
logging.getLogger("urllib3.connectionpool").addFilter(
|
|
||||||
NoHeaderErrorFilter()
|
|
||||||
)
|
|
||||||
|
|
||||||
self._auth = None
|
self._auth = None
|
||||||
if self._username and self._password:
|
if self._username and self._password:
|
||||||
if self._authentication == HTTP_BASIC_AUTHENTICATION:
|
if self._authentication == HTTP_BASIC_AUTHENTICATION:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user