Use HTTP_OK constant (#33798)
* Use http ok constant * Remove incorrect use * Run isort * Fix pylint by adding missing imports * Fix pylint by fixing one import
This commit is contained in:
parent
7383e81609
commit
8d61893c39
79 changed files with 214 additions and 154 deletions
|
@ -9,7 +9,7 @@ from homeassistant.components.device_tracker import (
|
|||
PLATFORM_SCHEMA,
|
||||
DeviceScanner,
|
||||
)
|
||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME, HTTP_OK
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -112,7 +112,7 @@ def _retrieve_list(host, token, **kwargs):
|
|||
except requests.exceptions.Timeout:
|
||||
_LOGGER.exception("Connection to the router timed out at URL %s", url)
|
||||
return
|
||||
if res.status_code != 200:
|
||||
if res.status_code != HTTP_OK:
|
||||
_LOGGER.exception("Connection failed with http code %s", res.status_code)
|
||||
return
|
||||
try:
|
||||
|
@ -150,7 +150,7 @@ def _get_token(host, username, password):
|
|||
except requests.exceptions.Timeout:
|
||||
_LOGGER.exception("Connection to the router timed out")
|
||||
return
|
||||
if res.status_code == 200:
|
||||
if res.status_code == HTTP_OK:
|
||||
try:
|
||||
result = res.json()
|
||||
except ValueError:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue