Require core config detection to be triggerd manually (#24019)

* Detect core config

* Remove elevation

* Lint

* Lint

* Fix type
This commit is contained in:
Paulus Schoutsen
2019-05-22 17:24:46 -07:00
committed by GitHub
parent f207e01510
commit 9e96397e6a
12 changed files with 188 additions and 323 deletions

View File

@@ -65,30 +65,6 @@ def distance(lat1: Optional[float], lon1: Optional[float],
return result * 1000
async def async_get_elevation(session: aiohttp.ClientSession, latitude: float,
longitude: float) -> int:
"""Return elevation for given latitude and longitude."""
try:
resp = await session.get(ELEVATION_URL, params={
'locations': '{},{}'.format(latitude, longitude),
}, timeout=5)
except (aiohttp.ClientError, asyncio.TimeoutError):
return 0
if resp.status != 200:
return 0
try:
raw_info = await resp.json()
except (aiohttp.ClientError, ValueError):
return 0
try:
return int(float(raw_info['results'][0]['elevation']))
except (ValueError, KeyError, IndexError):
return 0
# Author: https://github.com/maurycyp
# Source: https://github.com/maurycyp/vincenty
# License: https://github.com/maurycyp/vincenty/blob/master/LICENSE