MJPEG Camera Log Filter Fixes (#17050)

* Move filter to setup platform

* pylint
This commit is contained in:
Charles Garwood authored and Paulus Schoutsen committed 2018-10-02 10:24:44 +02:00
1 parent 90f71261c5
commit 0954eefa9f
1 file changed
+8 -4
+8 -4
View File
@@ -44,6 +44,14 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
async def async_setup_platform(hass, config, async_add_entities,
discovery_info=None):
"""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:
config = PLATFORM_SCHEMA(discovery_info)
async_add_entities([MjpegCamera(config)])
@@ -74,10 +82,6 @@ class MjpegCamera(Camera):
self._mjpeg_url = device_info[CONF_MJPEG_URL]
self._still_image_url = device_info.get(CONF_STILL_IMAGE_URL)
logging.getLogger("urllib3.connectionpool").addFilter(
NoHeaderErrorFilter()
)
self._auth = None
if self._username and self._password:
if self._authentication == HTTP_BASIC_AUTHENTICATION: