mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-06-29 13:00:02 +02:00
weather: don't crash when no city
This commit is contained in:
parent
852cb4967b
commit
911ba9c0ff
1 changed files with 3 additions and 7 deletions
10
bin/weather
10
bin/weather
|
@ -25,13 +25,9 @@ def get_location():
|
|||
r.raise_for_status()
|
||||
data = r.json()
|
||||
logger.debug("current location data: %s", data)
|
||||
logger.info(
|
||||
f'current location: {data["city"]["names"]["en"]}, {data["country"]["names"]["en"]}'
|
||||
)
|
||||
return (
|
||||
(data["location"]["latitude"], data["location"]["longitude"]),
|
||||
(data.get("city") or data["country"])["names"]["en"],
|
||||
)
|
||||
location = (data.get("city") or data["country"])["names"]["en"]
|
||||
logger.info(f"current location: {location}")
|
||||
return ((data["location"]["latitude"], data["location"]["longitude"]), location)
|
||||
|
||||
|
||||
def get_weather(apikey, latitude, longitude):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue