[minor] try re-read yaml in case it failed

This commit is contained in:
Marcel Paffrath 2022-12-21 11:57:37 +01:00
parent bf82148449
commit b17ee1288c

View File

@ -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):