Code: Select all
DATA_SOURCE = "https://exchange-rates.abstractapi.com/v1/live/?api_key=" + secrets['abstract'] + "&base=USD&target=CAD"
# {"base":"USD","last_updated":1679404500,"exchange_rates":{"EUR":0.927214}}
last_updated_LOCATION = ['last_updated']
EUR_LOCATION = ['exchange_rates', 'CAD']
cwd = ("/"+__file__).rsplit('/', 1)[0]
pyportal = PyPortal(url=DATA_SOURCE,
json_path=(EUR_LOCATION, last_updated_LOCATION),
text_font = cwd+"/fonts/6x10.bdf",
text_position=((5,25), (190, 25)),
text_color=(0xffff00, 0xffff00),
status_neopixel=board.NEOPIXEL,
default_bg=cwd+"/cta_black_splash.bmp"
)
pyportal.preload_font()
while True:
try:
value = pyportal.fetch()
except RuntimeError as e:
print("Some error occured, retrying! -", e)
print(value)
time.sleep(60)
Can I easily prevent that from happening?