PyPortal: Astronomy NASA: Network Error

Play with it! Please tell us which board you're using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
fhayes
 
Posts: 26
Joined: Tue Dec 08, 2015 7:17 pm

PyPortal: Astronomy NASA: Network Error

Post by fhayes »

Receiving HTTP 422 error trying to load NASA Astronomy image of the day. The output text is below.
Am I makinng an obvious error?

PyPortal
Circuit Python 7.0.0
Library Bundle: adafruit-circuitpython-bundle-7.x-mpy-20211116

I followed the learn guidelines and validated that the NASA image exists and loaded. I successfully tested ESP32 WiFi connectivity to my home network.

Repl Output (I did edit to delete the AIO Key)
_____________________________________________________________________________________
Connecting to AP 240_Swing
Retrieving data...Reply is OK!
original URL: https://apod.nasa.gov/apod/image/2111/G ... in_960.jpg
convert URL: https://io.adafruit.com/api/v2/fhayes/i ... x-aio-key=[My AIO Key]&width=320&height=240&output=BMP16&url=https://apod.nasa.gov/apod/image/2111/G ... in_960.jpg
Fetching stream from https://io.adafruit.com/api/v2/fhayes/i ... in_960.jpg
Traceback (most recent call last):
File "code.py", line 29, in <module>
File "adafruit_pyportal/__init__.py", line 333, in fetch
File "adafruit_pyportal/network.py", line 191, in process_image
File "adafruit_portalbase/network.py", line 280, in wget
HttpError: Code 422: Unprocessable Entity

Code done running.
Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.

Press any key to enter the REPL. Use CTRL-D to reload.

Adafruit CircuitPython 7.0.0 on 2021-09-20; Adafruit PyPortal with samd51j20
______________________________________________________________

User avatar
fhayes
 
Posts: 26
Joined: Tue Dec 08, 2015 7:17 pm

Re: PyPortal: Astronomy NASA: Network Error

Post by fhayes »

New Day; different error. I have not changed the code; simply brought in the library and code.py from the learn guideline.
Still failing on line 29 in code.py
response = pyportal.fetch()
_________________________________________________________________________________

Connecting to AP 240_Swing
Retrieving data...Reply is OK!
original URL: https://apod.nasa.gov/apod/image/2111/N ... ng_960.jpg
convert URL: https://io.adafruit.com/api/v2/fhayes/i ... ng_960.jpg
Fetching stream from https://io.adafruit.com/api/v2/fhayes/i ... ng_960.jpg
Reply is OK!
Saving data to /sd/cache.bmp
...............................................................................................................................................................................................................................................................................................................Created file of 153738 bytes in 11.5 seconds
Traceback (most recent call last):
File "code.py", line 29, in <module>
File "adafruit_pyportal/__init__.py", line 354, in fetch
File "adafruit_portalbase/__init__.py", line 406, in _fill_text_labels
File "adafruit_portalbase/__init__.py", line 357, in _fetch_set_text
File "adafruit_portalbase/__init__.py", line 252, in set_text
File "adafruit_display_text/bitmap_label.py", line 87, in __init__
File "adafruit_display_text/__init__.py", line 240, in __init__
File "adafruit_display_text/__init__.py", line 261, in _get_ascent_descent
File "adafruit_bitmap_font/bdf.py", line 75, in ascent
OSError: [Errno 22] Invalid argument

Code done running.

Press any key to enter the REPL. Use CTRL-D to reload.

Adafruit CircuitPython 7.0.0 on 2021-09-20; Adafruit PyPortal with samd51j20

__________________________________________________________________________

User avatar
fhayes
 
Posts: 26
Joined: Tue Dec 08, 2015 7:17 pm

Re: PyPortal: Astronomy NASA: Network Error

Post by fhayes »

PyPortal NASA Image Viewer still does not work correctly.

I downgraded the NASA program on Pyportal to CP 6.3.0. I am Still seeing an error somewhere within pyportal.fetch(). Error output for CP 6.3.0 is the same as CP 7.0.0.
In adafruit_bitmap_font/pdf.py line 75 is where the fault occurs and this has something to do with parsing through fonts/Arial-12.bdf.
line 75: self.file.readline()
I tried to remove that code section as an error source by substituting a modified bdf.py for bdf.mpy. I examined Arial-12.bdf and manually set the values for self._ascent = 11 and self._descent = 2 in bdf.py.
_____________________________________________________________
def ascent(self):
"""The number of pixels above the baseline of a typical ascender"""
if self._ascent is None:
self.file.seek(0)
self._ascent = 11
# while True:
# line = self.file.readline()
# line = str(line, "utf-8")
# if not line:
# break

# if line.startswith("FONT_ASCENT "):
# self._ascent = int(line.split()[1])
# break

return self._ascent
______________________________________________________

But this did not solve the issue - I just got another error on bdf.py/line ~144 also seemed to fail on a call to self.file.readline(). This was in a call to load_glyphs(self, code_points)

User avatar
fhayes
 
Posts: 26
Joined: Tue Dec 08, 2015 7:17 pm

Re: PyPortal: Astronomy NASA: Network Error

Post by fhayes »

PyPortal: NASA Daily Image - still not working.
I've experimented with CP 6.3 and 7.0 without success. From long experience in computer programming, I am operating on the assumption that the issue is something I have done wrong. Nonetheless, no further progress. I created a minimally viable program which failed if I included a specification for the font in the instantiation of PyPortal object.
_______________________________________
import board
import time
from adafruit_pyportal import PyPortal
from adafruit_bitmap_font import bitmap_font

cwd = ("/"+__file__).rsplit('/', 1)[0] # the current working directory (where this file is)
strText_Font = (cwd + "/fonts/Arial-12.bdf")
print("font = ", strText_Font)
# create pyportal object w no data source )
pyportal = PyPortal (
url = None,
json_path = None,
status_neopixel = board.NEOPIXEL,
default_bg = None,
text_position = (30,120),
text_font = strText_Font,
text_color= 0x00ff00
)
print("just past instatiation of pyportal")
i = 0
while True:
pyportal.text_position = (10, 10)
pyportal.set_text("How Now Ecru Bovine ", i)
i=i+1
time.sleep(5)
_________________________________________________________

User avatar
adafruit_support_carter
 
Posts: 29056
Joined: Tue Nov 29, 2016 2:45 pm

Re: PyPortal: Astronomy NASA: Network Error

Post by adafruit_support_carter »

Are you using latest library versions taken from downloaded bundle?
https://circuitpython.org/libraries

User avatar
fhayes
 
Posts: 26
Joined: Tue Dec 08, 2015 7:17 pm

Re: PyPortal: Astronomy NASA: Network Error

Post by fhayes »

Thank you for responding.

I have tried things with CP version 6.3 and 7.0. I've used the CP bundle from CircuitPython.org _and_ used the zipped files from the learn guide. In all four cases -> an error occurs in adafruit_bitmap_font/bdf.mpy. I reproduced the error with three different learn guidleines as well as PyPortal and PyPortal Titan devices.

adafruit-circuitpython-bundle-6.x-mpy-20211118
adafruit-circuitpython-bundle-py-20211118 i downloaded this to view adafruit_bitmap_font/bdf.py
adafruit-circuitpython-bundle-7.x-mpy-20211117

PyPortal_NASA
PyPortal_OpenWeather
PyPortal_Titano_Weather_Station

User avatar
adafruit_support_carter
 
Posts: 29056
Joined: Tue Nov 29, 2016 2:45 pm

Re: PyPortal: Astronomy NASA: Network Error

Post by adafruit_support_carter »

Did you do the changes needed for setting up boot.py?
https://learn.adafruit.com/pyportal-nas ... -3027533-9

User avatar
fhayes
 
Posts: 26
Joined: Tue Dec 08, 2015 7:17 pm

Re: PyPortal: Astronomy NASA: Network Error

Post by fhayes »

Yes, changes made to boot. I get a warning message when the device powers up. I'm going go through a complete systematic build (zero out the files first) of the learning guide.

User avatar
adafruit_support_carter
 
Posts: 29056
Joined: Tue Nov 29, 2016 2:45 pm

Re: PyPortal: Astronomy NASA: Network Error

Post by adafruit_support_carter »

I just tested the NASA Image of the Day code on a PyPortal running Circuit Python 7.0.0:
https://learn.adafruit.com/pyportal-nas ... age-viewer
and it ran OK. So everything should work as shown.

One thing to try is grabbing the code and assets all together via the Project Bundle:
bundle.jpg
bundle.jpg (29.07 KiB) Viewed 786 times
That will give you a .zip file with everything you need in one place.

Locked
Please be positive and constructive with your questions and comments.

Return to “Circuit Playground Classic, Circuit Playground Express, Circuit Playground Bluefruit”