From 6b0c7b4c1d53ca48fb202527bef8df573c0966c5 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Fri, 13 Aug 2021 23:01:13 +0200 Subject: [PATCH] polybar-weather: try harder to wait to be online --- bin/polybar-weather | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/bin/polybar-weather b/bin/polybar-weather index ad9c164..79c0dee 100755 --- a/bin/polybar-weather +++ b/bin/polybar-weather @@ -133,20 +133,21 @@ if __name__ == "__main__": try: # Get location - try: - location, city = get_location() - except requests.exceptions.ConnectionError: - # Wait to be online - logger.info("not online, waiting") - update_status("", options.output) - time.sleep(5) - process = subprocess.run( - ["nm-online", "-q", "-t", str(options.online_timeout * 60)] - ) - if process.returncode != 0: - logger.warning("not online, exiting") - sys.exit(1) - location, city = get_location() + while True: + try: + location, city = get_location() + break + except requests.exceptions.ConnectionError: + # Wait to be online + logger.info("not online, waiting") + update_status("", options.output) + time.sleep(5) + process = subprocess.run( + ["nm-online", "-q", "-t", str(options.online_timeout * 60)] + ) + if process.returncode != 0: + logger.warning("not online, exiting") + sys.exit(1) # Grab current weather and daily forecast weather = get_weather(options.owm_api_key, *location)