MPY tool - manage files on devices running MicroPython
It is an alternative to ampy
Target of this project is to make more clean code, faster, better verbose output...
pip3 install mpytool
help:
$ mpytool --help
list files:
$ mpytool -p /dev/ttyACM0 ls
$ mpytool -p /dev/ttyACM0 ls lib
tree files:
$ mpytool -p /dev/ttyACM0 tree
upload file or whole directory:
$ mpytool -p /dev/ttyACM0 put boot.py
$ mpytool -vp /dev/ttyACM0 put app/lib
$ mpytool -vp /dev/ttyACM0 --exclude-dir build --exclude-dir dist put app/src light_control
view content of file or download:
$ mpytool -p /dev/ttyACM0 get boot.py
$ mpytool -p /dev/ttyACM0 get net.py >> net.py
make directory, erase dir or files:
$ mpytool -p /dev/ttyACM0 mkdir a/b/c/d xyz/abc
$ mpytool -p /dev/ttyACM0 delete a xyz
reset only, reset and follow output, REPL mode:
$ mpytool -p /dev/ttyACM0 reset
$ mpytool -p /dev/ttyACM0 reset follow
$ mpytool -p /dev/ttyACM0 repl
>>> import mpytool
>>> conn = mpytool.ConnSerial(port='/dev/ttyACM0', baudrate=115200)
>>> mpy = mpytool.Mpy(conn)
>>> mpy.ls()
[('ehome', None), ('boot.py', 215), ('net.py', 2938), ('project.json', 6404)]
>>> mpy.mkdir('a/b/c')
>>> mpy.ls()
[('a', None),
('ehome', None),
('boot.py', 215),
('net.py', 2938),
('project.json', 6404)]
>>> mpy.get('boot.py')
b"import time\nimport net\n\nwlan = net.Wlan()\nwlan.refresh_network()\n\nwhile wlan.ifconfig()[0] == '0.0.0.0':\n time.sleep(.1)\n\nprint('IP: ' + wlan.ifconfig()[0])\n\nimport ehome.ehome\n\nehome.ehome.start('project.json')\n"
>>> mpy.delete('a/b')
use -v
or -vv
to show verbose output (like currently processing file, ..)
- normally print only errors (red)
-d
print warnings (yellow)-dd
print info messages (purple)-ddd
print debug messages (blue)
for reporting bugs, please provide in to issue also -ddd messages
for test used: ESP32S2 over USB 2MB RAM and 4MB FLASH:
recursive put of 30 files in 4 folders, 70KB total:
- mpytool: 12.3s
- mpremote: 16.5s
- ampy: 79.3s
- rshell: 81.1s
Working only with MicroPython boards, not with CircuitPython
- python v3.6+
- pyserial v3.0+
- Linux
- MacOS
- Windows (REPL mode is disabled)
(c) 2022 by Pavel Revak
MIT
- Basic support is free over GitHub issues.
- Professional support is available over email: Pavel Revak.