polybar-weather: try harder to wait to be online

This commit is contained in:
Vincent Bernat 2021-08-13 23:01:13 +02:00
parent 481b258fe0
commit 6b0c7b4c1d

View file

@ -133,20 +133,21 @@ if __name__ == "__main__":
try: try:
# Get location # Get location
try: while True:
location, city = get_location() try:
except requests.exceptions.ConnectionError: location, city = get_location()
# Wait to be online break
logger.info("not online, waiting") except requests.exceptions.ConnectionError:
update_status("", options.output) # Wait to be online
time.sleep(5) logger.info("not online, waiting")
process = subprocess.run( update_status("", options.output)
["nm-online", "-q", "-t", str(options.online_timeout * 60)] time.sleep(5)
) process = subprocess.run(
if process.returncode != 0: ["nm-online", "-q", "-t", str(options.online_timeout * 60)]
logger.warning("not online, exiting") )
sys.exit(1) if process.returncode != 0:
location, city = get_location() logger.warning("not online, exiting")
sys.exit(1)
# Grab current weather and daily forecast # Grab current weather and daily forecast
weather = get_weather(options.owm_api_key, *location) weather = get_weather(options.owm_api_key, *location)