Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GET fails with CircuitPython #110

Open
jerryneedell opened this issue Jan 26, 2022 · 0 comments
Open

GET fails with CircuitPython #110

jerryneedell opened this issue Jan 26, 2022 · 0 comments

Comments

@jerryneedell
Copy link

jerryneedell commented Jan 26, 2022

The "get" command imports ubinascii but CircuitPython now uses binascii, so it fails with:

jerryneedell@jerryneedell-ubuntu-macmini:~/projects/microbit_v2$ ampy get code.py
Traceback (most recent call last):
  File "/home/jerryneedell/.local/bin/ampy", line 8, in <module>
    sys.exit(cli())
  File "/home/jerryneedell/.local/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/jerryneedell/.local/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/jerryneedell/.local/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/jerryneedell/.local/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/jerryneedell/.local/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/jerryneedell/.local/lib/python3.8/site-packages/ampy/cli.py", line 126, in get
    contents = board_files.get(remote_file)
  File "/home/jerryneedell/.local/lib/python3.8/site-packages/ampy/files.py", line 82, in get
    raise ex
  File "/home/jerryneedell/.local/lib/python3.8/site-packages/ampy/files.py", line 74, in get
    out = self._pyboard.exec_(textwrap.dedent(command))
  File "/home/jerryneedell/.local/lib/python3.8/site-packages/ampy/pyboard.py", line 279, in exec_
    raise PyboardError('exception', ret, ret_err)
ampy.pyboard.PyboardError: ('exception', b'', b'Traceback (most recent call last):\r\n  File "<stdin>", line 3, in <module>\r\nImportError: no module named \'ubinascii\'\r\n')

this can be fixed by modifying files.py at line 62 to replace
import ubinascii
with

            try:
                import ubinascii
            except:
                import binascii as ubinascii

with this change:

jerryneedell@jerryneedell-ubuntu-macmini:~/projects/microbit_v2$ ampy get code.py
print("Hello World!")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant