Skip to content
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

fixed bugs with 'ls'. Added recursive to 'ls', along with some beauty… #56

Merged
merged 3 commits into from
Jul 23, 2018

Conversation

devxpy
Copy link
Member

@devxpy devxpy commented Jul 20, 2018

  • fix ls does not work for subdirectories #55.
  • Add a recursive mode to ls command.
  • Always display the file/dir names as the full path with a leading slash for least confusion.
  • Code format with black (my editor was rigged to do it, sorry).

Tested on Wemos D1 Mini


Here are some examples of what I did -

(... == -p /dev/ttyUSB0 -b 115200)

⋊ ~/ampy> ampy ... ls -r -l
/boot.py - 0 bytes
/glove/common/__init__.mpy - 82 bytes
/glove/common/config.mpy - 302 bytes
/glove/common/unetwork.mpy - 5956 bytes
/glove/micropython/__init__.mpy - 82 bytes
/glove/micropython/glove.mpy - 915 bytes
/glove/micropython/imu.mpy - 8321 bytes
/glove/micropython/mpu9250.mpy - 4472 bytes
/glove/micropython/vector3d.mpy - 4081 bytes
/main.py - 30 bytes
⋊ ~/ampy> ampy ...  ls -r /glove
/glove/common/__init__.mpy
/glove/common/config.mpy
/glove/common/unetwork.mpy
/glove/micropython/__init__.mpy
/glove/micropython/glove.mpy
/glove/micropython/imu.mpy
/glove/micropython/mpu9250.mpy
/glove/micropython/vector3d.mpy

The leading slash is automatically added, if not present.

⋊ ~/ampy> ampy ...  ls glove
/glove/common
/glove/micropython
⋊ ~/ampy> ampy ...  ls -l glove/common 
/glove/common/__init__.mpy - 82 bytes
/glove/common/config.mpy - 302 bytes
/glove/common/unetwork.mpy - 5956 bytes

I tried to stick to the code style you guys have, but this is the best I could do.

Please accept this request, navigating the directory structure is a real pain right now. Hopefully, this pull request makes it easier for everyone.

Thanks!


P.S. Try out this pull request in your nearest personal computer today!

$ git clone https://github.com/devxpy/ampy.git
$ cd ampy
$ pip install -e .

🐍🏕️

@jerryneedell
Copy link

tried it on my feather52832 -- works well!

jerryneedell@Ubuntu-Macmini:~/projects/feather52$ ampy ls -r
/I2S_Test_Script.py
/adafruit_stmpe610.mpy
/am2320_test.py
/ble_scan.py
/i2c_scan.py
/lib/adafruit_bus_device/__init__.py
/lib/adafruit_bus_device/i2c_device.mpy
/lib/adafruit_bus_device/spi_device.mpy
/lib/adafruit_sdcard.mpy
/lis3dh_simpletest.py
/paint_nrf52.py
/sdmount.py
/sdmount_lib.py
/stmpe.py
/stmpe610_i2c.py
/stmpe610_spi.py

@jerryneedell
Copy link

and on an esp8266 -- nice!

jerryneedell@Ubuntu-Macmini:~/projects/esp8266/ampy$ ampy ls
/boot.py
/jewel.py
/lib
jerryneedell@Ubuntu-Macmini:~/projects/esp8266/ampy$ ampy ls -r
/boot.py
/jewel.py
/lib/neopixel.mpy
jerryneedell@Ubuntu-Macmini:~/projects/esp8266/ampy$ ampy ls lib
/lib/neopixel.mpy
jerryneedell@Ubuntu-Macmini:~/projects/esp8266/ampy$ 

@devxpy
Copy link
Member Author

devxpy commented Jul 20, 2018

Also, tests run fine here.

⋊ ~/a/tests> python test_files.py 
...............
----------------------------------------------------------------------
Ran 15 tests in 0.006s

OK

Copy link
Contributor

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ls does not work for subdirectories
3 participants