Better handle file not found when loading YAML (#23908)

* Better handle file not found

* Lint
This commit is contained in:
Paulus Schoutsen authored and GitHub committed 2019-05-19 12:01:29 +02:00
1 parent f991ec15f2
commit e356d0bcda
4 files changed
+11 -11

No files matched your search

+2 -4
View File
@@ -3,7 +3,6 @@ from collections import defaultdict
from datetime import datetime
from ipaddress import ip_address
import logging
import os
from aiohttp.web import middleware
from aiohttp.web_exceptions import HTTPForbidden, HTTPUnauthorized
@@ -155,11 +154,10 @@ async def async_load_ip_bans_config(hass: HomeAssistant, path: str):
"""Load list of banned IPs from config file."""
ip_list = []
if not os.path.isfile(path):
return ip_list
try:
list_ = await hass.async_add_executor_job(load_yaml_config_file, path)
except FileNotFoundError:
return ip_list
except HomeAssistantError as err:
_LOGGER.error('Unable to load %s: %s', path, str(err))
return ip_list