-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
tools/pyboard.py: Add filesystem commands to ls/cat/cp/rm remote files. #4917
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
Conversation
Yes, exactly. And given that the primary(?) use most people would have for pyboard.py is as an internal dependency for |
If that's true then people are missing out! I use pyboard.py all the time as a fast way to iterate -- it's a really useful middle ground between the REPL and putting files on the board (using ampy/rshell/USB-MSC). Also, I always have the micropython repo available on my computer, it's always up to date and I don't have to put any cognitive effort into using pyboard.py. ampy / rshell, while great (especially rshell), is something else to think about and manage. People may not have packages available for their distro, etc. Huge +1 from me on this PR - thanks for implementing @dpgeorge |
If you look at https://store.micropython.org/product/PYBv1.0 you'll see that |
There's definitely more and more growing/visible conceptual conflict between MicroPython as open-source project and MicroPython as a product of a particular vendor.
Then you're again a bit too late with adding pretty obvious and useful functionality. And given that other community-driven projects exist to cover that functionality, it won't escape a thorough reader's attention that there's a bit of NIH attitude. That's what mostly the note is about.
|
An alternative to using
It saves one character for each command but looks a bit strange to me. |
This would have a side benefit of including these filesystem commands in the |
I'm not sure it'd be this easy because these options would probably be implemented as store-true so couldn't parse their args. Also I think it'd be confusing to allow multiple of these commands to be specified at once. I picked |
Ok, merged as-is in 4d94fae |
This PR adds a simple interface to the
tools/pyboard.py
script to deal with files on the remote MicroPython target. It adds it in two parts: 1) a set offs_XX()
functions added to thePyboard
class; 2) a command-line interface which wraps these functions in a user friendly way.The CLI is accessed by using the
-f
option to the script then following with standard filesystem commands like ls, cat, cp, rm, mkdir, rmdir. Multiple files are supported by these commands, eg copying multiple files at once. In most cases the tool can detect when a file refers to a local file or a remote file. In cases where it's ambiguous, or the user wants to be sure, the:
character can be prepended to a filename to indicate its on the remote MicroPython device.Some example usage:
The functionality should work on any MicroPython device with file support. At least
cat
andcp
will work on pretty much anything because they only rely onopen()
andprint()
. The other functions rely on theuos
module.There are a lot of other third-party tools out there that do similar things (eg rshell, ampy), but I think it's important and useful to have official support in this repository for file transfer over the REPL.