mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +00:00
Filter urllib3.connectionpool warnings in camera.axis and camera.zoneminder (#19641)
* Filter urllib3.connectionpool warnings in camera.axis and camera.zoneminder * Lint
This commit is contained in:
parent
b79057348d
commit
c2525bede2
@ -7,7 +7,7 @@ https://home-assistant.io/components/camera.axis/
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.camera.mjpeg import (
|
from homeassistant.components.camera.mjpeg import (
|
||||||
CONF_MJPEG_URL, CONF_STILL_IMAGE_URL, MjpegCamera)
|
CONF_MJPEG_URL, CONF_STILL_IMAGE_URL, MjpegCamera, filter_urllib3_logging)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_AUTHENTICATION, CONF_HOST, CONF_NAME, CONF_PASSWORD, CONF_PORT,
|
CONF_AUTHENTICATION, CONF_HOST, CONF_NAME, CONF_PASSWORD, CONF_PORT,
|
||||||
CONF_USERNAME, HTTP_DIGEST_AUTHENTICATION)
|
CONF_USERNAME, HTTP_DIGEST_AUTHENTICATION)
|
||||||
@ -29,6 +29,8 @@ def _get_image_url(host, port, mode):
|
|||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
"""Set up the Axis camera."""
|
"""Set up the Axis camera."""
|
||||||
|
filter_urllib3_logging()
|
||||||
|
|
||||||
camera_config = {
|
camera_config = {
|
||||||
CONF_NAME: discovery_info[CONF_NAME],
|
CONF_NAME: discovery_info[CONF_NAME],
|
||||||
CONF_USERNAME: discovery_info[CONF_USERNAME],
|
CONF_USERNAME: discovery_info[CONF_USERNAME],
|
||||||
|
@ -46,7 +46,15 @@ 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
|
filter_urllib3_logging()
|
||||||
|
|
||||||
|
if discovery_info:
|
||||||
|
config = PLATFORM_SCHEMA(discovery_info)
|
||||||
|
async_add_entities([MjpegCamera(config)])
|
||||||
|
|
||||||
|
|
||||||
|
def filter_urllib3_logging():
|
||||||
|
"""Filter header errors from urllib3 due to a urllib3 bug."""
|
||||||
urllib3_logger = logging.getLogger("urllib3.connectionpool")
|
urllib3_logger = logging.getLogger("urllib3.connectionpool")
|
||||||
if not any(isinstance(x, NoHeaderErrorFilter)
|
if not any(isinstance(x, NoHeaderErrorFilter)
|
||||||
for x in urllib3_logger.filters):
|
for x in urllib3_logger.filters):
|
||||||
@ -54,10 +62,6 @@ async def async_setup_platform(hass, config, async_add_entities,
|
|||||||
NoHeaderErrorFilter()
|
NoHeaderErrorFilter()
|
||||||
)
|
)
|
||||||
|
|
||||||
if discovery_info:
|
|
||||||
config = PLATFORM_SCHEMA(discovery_info)
|
|
||||||
async_add_entities([MjpegCamera(config)])
|
|
||||||
|
|
||||||
|
|
||||||
def extract_image_from_mjpeg(stream):
|
def extract_image_from_mjpeg(stream):
|
||||||
"""Take in a MJPEG stream object, return the jpg from it."""
|
"""Take in a MJPEG stream object, return the jpg from it."""
|
||||||
|
@ -8,7 +8,7 @@ import logging
|
|||||||
|
|
||||||
from homeassistant.const import CONF_NAME, CONF_VERIFY_SSL
|
from homeassistant.const import CONF_NAME, CONF_VERIFY_SSL
|
||||||
from homeassistant.components.camera.mjpeg import (
|
from homeassistant.components.camera.mjpeg import (
|
||||||
CONF_MJPEG_URL, CONF_STILL_IMAGE_URL, MjpegCamera)
|
CONF_MJPEG_URL, CONF_STILL_IMAGE_URL, MjpegCamera, filter_urllib3_logging)
|
||||||
from homeassistant.components.zoneminder import DOMAIN as ZONEMINDER_DOMAIN
|
from homeassistant.components.zoneminder import DOMAIN as ZONEMINDER_DOMAIN
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@ -18,6 +18,7 @@ DEPENDENCIES = ['zoneminder']
|
|||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
"""Set up the ZoneMinder cameras."""
|
"""Set up the ZoneMinder cameras."""
|
||||||
|
filter_urllib3_logging()
|
||||||
zm_client = hass.data[ZONEMINDER_DOMAIN]
|
zm_client = hass.data[ZONEMINDER_DOMAIN]
|
||||||
|
|
||||||
monitors = zm_client.get_monitors()
|
monitors = zm_client.get_monitors()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user