From b17ee1288ca3b221b5baeb096d6f3b0de9d85809 Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 21 Dec 2022 11:57:37 +0100 Subject: [PATCH] [minor] try re-read yaml in case it failed --- survBot.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/survBot.py b/survBot.py index 17a8c83..ee4c211 100755 --- a/survBot.py +++ b/survBot.py @@ -36,9 +36,16 @@ CLR = "\x1B[0K" deg_str = '\N{DEGREE SIGN}C' -def read_yaml(file_path): - with open(file_path, "r") as f: - return yaml.safe_load(f) +def read_yaml(file_path, n_read=3): + for index in range(n_read): + try: + with open(file_path, "r") as f: + params = yaml.safe_load(f) + except Exception as e: + print(f'Could not read parameters file: {e}.\nWill try again {n_read - index - 1} time(s).') + time.sleep(10) + continue + return params def nsl_from_id(nwst_id):