Merge pull request #1417 from fabaff/freegeoip
Catch 503 responses by freegeoip.net (Fixes #1378)
This commit is contained in:
commit
4e750a4d72
1 changed files with 5 additions and 8 deletions
|
@ -1,7 +1,4 @@
|
|||
"""
|
||||
homeassistant.util.location
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Module with location helpers.
|
||||
|
||||
detect_location_info and elevation are mocked by default during tests.
|
||||
|
@ -26,8 +23,8 @@ def detect_location_info():
|
|||
try:
|
||||
raw_info = requests.get(
|
||||
'https://freegeoip.net/json/', timeout=5).json()
|
||||
except requests.RequestException:
|
||||
return
|
||||
except (requests.RequestException, ValueError):
|
||||
return None
|
||||
|
||||
data = {key: raw_info.get(key) for key in LocationInfo._fields}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue