mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-06-30 13:24:21 +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()
|
r.raise_for_status()
|
||||||
data = r.json()
|
data = r.json()
|
||||||
logger.debug("current location data: %s", data)
|
logger.debug("current location data: %s", data)
|
||||||
logger.info(
|
location = (data.get("city") or data["country"])["names"]["en"]
|
||||||
f'current location: {data["city"]["names"]["en"]}, {data["country"]["names"]["en"]}'
|
logger.info(f"current location: {location}")
|
||||||
)
|
return ((data["location"]["latitude"], data["location"]["longitude"]), location)
|
||||||
return (
|
|
||||||
(data["location"]["latitude"], data["location"]["longitude"]),
|
|
||||||
(data.get("city") or data["country"])["names"]["en"],
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def get_weather(apikey, latitude, longitude):
|
def get_weather(apikey, latitude, longitude):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue