mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 07:07:28 +00:00
Fix unnecessary warning for ip bans.yaml (#6417)
This commit is contained in:
parent
e8a22cb4a8
commit
10bf659773
@ -4,6 +4,7 @@ from collections import defaultdict
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from ipaddress import ip_address
|
from ipaddress import ip_address
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
|
||||||
from aiohttp.web_exceptions import HTTPForbidden, HTTPUnauthorized
|
from aiohttp.web_exceptions import HTTPForbidden, HTTPUnauthorized
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
@ -115,13 +116,14 @@ def load_ip_bans_config(path: str):
|
|||||||
"""Loading list of banned IPs from config file."""
|
"""Loading list of banned IPs from config file."""
|
||||||
ip_list = []
|
ip_list = []
|
||||||
|
|
||||||
|
if not os.path.isfile(path):
|
||||||
|
return ip_list
|
||||||
|
|
||||||
try:
|
try:
|
||||||
list_ = load_yaml_config_file(path)
|
list_ = load_yaml_config_file(path)
|
||||||
except FileNotFoundError:
|
|
||||||
return []
|
|
||||||
except HomeAssistantError as err:
|
except HomeAssistantError as err:
|
||||||
_LOGGER.error('Unable to load %s: %s', path, str(err))
|
_LOGGER.error('Unable to load %s: %s', path, str(err))
|
||||||
return []
|
return ip_list
|
||||||
|
|
||||||
for ip_ban, ip_info in list_.items():
|
for ip_ban, ip_info in list_.items():
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user