mirror of
https://github.com/home-assistant/core.git
synced 2025-06-05 05:37:04 +00:00
update depenency handling (requests)
This commit is contained in:
parent
1aa98bea2b
commit
da68e4ab11
@ -32,6 +32,7 @@ Details for the API : http://transport.opendata.ch
|
|||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
from requests import get
|
||||||
|
|
||||||
from homeassistant.util import Throttle
|
from homeassistant.util import Throttle
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
@ -47,17 +48,6 @@ MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=60)
|
|||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
""" Get the Swiss public transport sensor. """
|
""" Get the Swiss public transport sensor. """
|
||||||
|
|
||||||
try:
|
|
||||||
# pylint: disable=unused-variable
|
|
||||||
from requests import get
|
|
||||||
|
|
||||||
except ImportError:
|
|
||||||
_LOGGER.exception(
|
|
||||||
"Unable to import requests. "
|
|
||||||
"Did you maybe not install the 'Requests' package?")
|
|
||||||
|
|
||||||
return None
|
|
||||||
|
|
||||||
# journal contains [0] Station ID start, [1] Station ID destination
|
# journal contains [0] Station ID start, [1] Station ID destination
|
||||||
# [2] Station name start, and [3] Station name destination
|
# [2] Station name start, and [3] Station name destination
|
||||||
journey = []
|
journey = []
|
||||||
@ -121,8 +111,6 @@ class PublicTransportData(object):
|
|||||||
def update(self):
|
def update(self):
|
||||||
""" Gets the latest data from opendata.ch. """
|
""" Gets the latest data from opendata.ch. """
|
||||||
|
|
||||||
from requests import get
|
|
||||||
|
|
||||||
response = get(
|
response = get(
|
||||||
_RESOURCE +
|
_RESOURCE +
|
||||||
'connections?' +
|
'connections?' +
|
||||||
|
Loading…
x
Reference in New Issue
Block a user