Retrieving data...Traceback (most recent call last):
File "code.py", line 46, in <module>
File "code.py", line 40, in main
File "adafruit_pyportal/__init__.py", line 306, in fetch
File "adafruit_portalbase/network.py", line 478, in fetch
File "adafruit_requests.py", line 696, in get
File "adafruit_requests.py", line 578, in request
OutOfRetries: Repeated socket failures
I am running this code and after awhile I come back to my pyportal throwing this error message and I just want it to loop infinitely.
Code: Select all
import time
import board
from adafruit_pyportal import PyPortal
i = 0
#Set up where we'll be fetching data from
DATA_SOURCE = "http://192.168.1.67/presently-backup.json"
QUOTE_LOCATION = [i, "entryContent"]
AUTHOR_LOCATION = [i, "entryDate"]
#the current working directory (where this file is)
cwd = ("/"+__file__).rsplit('/', 1)[0]
var = (QUOTE_LOCATION, AUTHOR_LOCATION)
pyportal = PyPortal(url=DATA_SOURCE,
json_path=(QUOTE_LOCATION, AUTHOR_LOCATION),
#status_neopixel=board.NEOPIXEL,
default_bg=cwd+"/quote_background.bmp",
text_font=cwd+"/fonts/PTSans-BoldItalic.bdf",
text_position=((20, 120), # quote location
(210, 210)), # author location
text_color=(0x008080, # quote text color
0x8080FF), # author text color
text_wrap=(35, # characters to wrap for quote
0), # no wrap for author
text_maxlen=(190, 30), # max text size for quote & author
)
pyportal.preload_font()
def main(i):
print(i)
pyportal.json_path=([str(i),
'entryContent'],
[str(i),
'entryDate'],
)
# speed up projects with lots of text by preloading the font!
value = pyportal.fetch()
print("Response is", value)
while True:
try:
main(i)
i = i + 1
time.sleep(5)
if i == 75:
i = 0
except (ValueError, RuntimeError) as e:
print("Some error occured, retrying! -", e)
time.sleep(5)