ntoll / uflash

A module and command to easily flash Python onto the BBC's micro:bit device.
http://micropython.org/
MIT License
106 stars 27 forks source link

Flash multiple microbits at once #19

Closed tomviner closed 8 years ago

tomviner commented 8 years ago

Fix for https://github.com/ntoll/uflash/issues/18 Flash multiple microbits at once

The target argument can now occur any number of times.

$ uflash --help
usage: uflash [-h] [-r RUNTIME] [-e] [source] [target [target ...]]

i.e.

$ uflash setup.py /media/tom/MICROBIT /media/tom/MICROBIT1
Flashing Python to: /media/tom/MICROBIT/micropython.hex
Flashing Python to: /media/tom/MICROBIT1/micropython.hex

On Linux this allows shell expansions like:

$ uflash setup.py /media/tom/MICROBIT*
Flashing Python to: /media/tom/MICROBIT/micropython.hex
Flashing Python to: /media/tom/MICROBIT1/micropython.hex

or

$ uflash setup.py /media/tom/MICROBIT{,3,5}
Flashing Python to: /media/tom/MICROBIT/micropython.hex
Flashing Python to: /media/tom/MICROBIT3/micropython.hex
Flashing Python to: /media/tom/MICROBIT5/micropython.hex

Note: uflash does not receive (and cannot deal with) strings like /media/tom/MICROBIT*, rather shell expansion takes place, so the actual args passed into the script are /media/tom/MICROBIT /media/tom/MICROBIT1.

Windows doesn't do shell expansion, and even the glob module cannot reference multiple volumes, i.e. glob.glob('*:\\MICROBIT') never matches anything. So on Windows, one must pass n paths for n microbits. And the docs update shows just this - no * or {}.

Full list of changes:

Happy to alter / take any of these changes out, if they don't seem appropriate. Everything is in separate commits.

If you'd like Appveyor to run the tests on Windows automatically, I can add that too (in a separate PR).

ntoll commented 8 years ago

@tomviner this is great stuff! I've had a look around your changes but will need a bit more time to look in more detail. Put simply, I think this is wonderful but I need to update the docs as per your instructions and make some tox related changes before merging into master. Shouldn't take too long, although it ain't gonna happen today.

Thank you! :-)

ntoll commented 8 years ago

OK... I fixed a couple of niggles and merged. It works! Yay! Many many thanks for the contribution @tomviner.

tomviner commented 8 years ago

Great!