[minor] try re-read yaml in case it failed
This commit is contained in:
parent
bf82148449
commit
b17ee1288c
13
survBot.py
13
survBot.py
@ -36,9 +36,16 @@ CLR = "\x1B[0K"
|
|||||||
deg_str = '\N{DEGREE SIGN}C'
|
deg_str = '\N{DEGREE SIGN}C'
|
||||||
|
|
||||||
|
|
||||||
def read_yaml(file_path):
|
def read_yaml(file_path, n_read=3):
|
||||||
with open(file_path, "r") as f:
|
for index in range(n_read):
|
||||||
return yaml.safe_load(f)
|
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):
|
def nsl_from_id(nwst_id):
|
||||||
|
Loading…
Reference in New Issue
Block a user