Get command does not work with byte files
FlorianPoot opened this issue · 1 comments
FlorianPoot commented
Hello,
Sometimes the get command does not work with byte files such as PNG images. This may be because images sometimes contain \x04 in the file. I'm trying to get this image in my ESP8266 board under MicroPython 1.11
Here is the exception I get
PS C:\Program Files\Python38\Scripts> ./ampy --port COM6 get 74374545_774864752975256_6588784590058422272_n.png
Traceback (most recent call last):
File "c:\program files\python38\lib\site-packages\ampy\files.py", line 72, in get
out = self._pyboard.exec_(textwrap.dedent(command))
File "c:\program files\python38\lib\site-packages\ampy\pyboard.py", line 267, in exec_
raise PyboardError('exception', ret, ret_err)
ampy.pyboard.PyboardError: ('exception', b'\x89PNG\r\r\n\x1a\r\n\x00\x00\x00\rIHDR\x00\x00\x07\x80\x00\x00', b'8\x08\x06\x00\x00\x00\xe8\xd3\xc1C\x00\x00 \x00IDATx^\xec\xddQ\x88\x9c\xe7\xb9\'\xf8\xa7"]-\x0b]w\xc5\\\x05\x14\xa9\x86\xc4\t\xc7(\xf6\xb2\x96\x07\xc6Lh\x88\xecsq\x0c\xb2\xaf\x96\xc4\xcb\x82\x9b\x15t\xdcsq\xc2 \xa7\x89B\xc5b\xf0\xb98r\x1a4\xc80\x8cc\xf6J\x16\xe8\\\xc4\x96\xa1\xc9\x92\x8b\xb14\xac\x1c\xe3%qB\x97t')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\program files\python38\lib\runpy.py", line 192, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\program files\python38\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Program Files\Python38\Scripts\ampy.exe\__main__.py", line 7, in <module>
File "c:\program files\python38\lib\site-packages\click\core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "c:\program files\python38\lib\site-packages\click\core.py", line 717, in main
rv = self.invoke(ctx)
File "c:\program files\python38\lib\site-packages\click\core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\program files\python38\lib\site-packages\click\core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\program files\python38\lib\site-packages\click\core.py", line 555, in invoke
return callback(*args, **kwargs)
File "c:\program files\python38\lib\site-packages\ampy\cli.py", line 126, in get
contents = board_files.get(remote_file)
File "c:\program files\python38\lib\site-packages\ampy\files.py", line 76, in get
if ex.args[2].decode("utf-8").find("OSError: [Errno 2] ENOENT") != -1:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe8 in position 6: invalid continuation byte
PS C:\Program Files\Python38\Scripts>
Thanks !
FlorianPoot commented
Sorry, I just understood that the issue has already been solved. It's the package on PyPi that is not up to date. It might be a good idea to update it...