Skip to content

GET fails with CircuitPython  #110

Description

@jerryneedell

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!")

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions