Open jerryneedell opened 2 years ago
I have no authority here, but issue #110 is something that has been annoying in ampy for some time. I have implemented the above fix locally and confirm that it works and is non-breaking for micropython devices as well. I would like to see this merged.
For what it's worth, I tested this on an HUZZAH32 V2 running:
adafruit-ampy (1.1.0)
Adafruit CircuitPython 8.1.0 on 2023-05-22; Adafruit Feather ESP32 V2 with ESP32
I was unable to make this work, it appears that the left over item is now:
# files.py
def get(self, filename):
"""Retrieve the contents of the specified file and return its contents
as a byte string.
"""
# Open the file and read it a few bytes at a time and print out the
# raw bytes. Be careful not to overload the UART buffer so only write
# a few bytes at a time, and don't use print since it adds newlines and
# expects string data.
command = """
import sys
import binascii
with open('{0}', 'rb') as infile:
while True:
result = infile.read({1})
if result == b'':
break
# len = sys.stdout.write(ubinascii.hexlify(result))
# use actual binascii
len = sys.stdout.write(binascii.hexlify(result))
The above patch correct it for me, which I assume is just a missed merge between your changes and the circuit python project.
addresses #110 Circuitpython now uses binascii so the "get" command fails trying to import ubinascii. This PR adds a try/except to import binascii as ubinascii if ubinascii is not present.