mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-07-16 05:04:21 +02:00
polybar-weather: add a timeout to requests
This commit is contained in:
parent
4d350646c0
commit
5da755a496
1 changed files with 3 additions and 1 deletions
|
@ -20,6 +20,7 @@ def get_location():
|
|||
r = requests.get(
|
||||
"https://www.maxmind.com/geoip/v2.1/city/me",
|
||||
headers={"referer": "https://www.maxmind.com/en/locate-my-ip-address"},
|
||||
timeout=10,
|
||||
)
|
||||
r.raise_for_status()
|
||||
data = r.json()
|
||||
|
@ -45,6 +46,7 @@ def get_weather(apikey, latitude, longitude):
|
|||
"units": "metric",
|
||||
"exclude": "minutely,hourly",
|
||||
},
|
||||
timeout=10,
|
||||
)
|
||||
r.raise_for_status()
|
||||
data = r.json()
|
||||
|
@ -145,7 +147,7 @@ if __name__ == "__main__":
|
|||
try:
|
||||
location, city = get_location()
|
||||
break
|
||||
except requests.exceptions.ConnectionError:
|
||||
except (requests.exceptions.ConnectionError, requests.exceptions.Timeout):
|
||||
# Wait to be online
|
||||
logger.info("not online, waiting")
|
||||
update_status("", options.output)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue