pip3 install mpy-utils
It is awfully slow, but seems to work pretty well. Most of the hard work was already done by the excellent fusepy, and thanks to Damien and pyboard.py for the hints on how to get Micropython REPL working in raw mode.
Rather unexpectedly, Tony D from Adafruit made a youtube video about mpy-utils which was quite interesting to see, as it points out quite a few flaws in the package. I’ve tried to turn them into github issues …
Sometimes stupid is better than clever.
I was presenting mpy-utils at the MicroPython Meetup including the nifty FUSE-only-works-on-Linux-and-OSX bit, and one of the members said
aha, I know how you do this, you just poll the files and then send the changes!
Well, no, we did something much cleverer by mounting the whole thing as a filesystem, but that got me thinking: FUSE is clever, but is also responsible for issues #1, #5, #6, #7 … perhaps stupid would be better?
So version 0.1.6 of mpy-utils now includes
mpy_watch which works exactly in the most
obvious way: it polls your files for changes every second and sends them when they change.
It also keeps a copy in memory and sends only the differences, using Python’s difflib to work that out. That makes it far, far quicker for the usual case. And there’s a filename filter in place to stop it trying to send crazy editor tempfiles and stuff.
- it could avoid polling using one of the cross-platform watchdogs
- it could be a bit smarter about binaries.
- the diff could look a little more closely at text to insert/replace to see if it can save even more bytes
- the code is pretty dismal but it’s 2am here so that can wait