dhylands / rshell

Remote Shell for MicroPython
MIT License
955 stars 136 forks source link

Implement df command using os.statvfs #226

Closed amaksoft closed 6 months ago

amaksoft commented 7 months ago

It's a bit inconvenient that rshell has no easy way to check disk space availability on device partitions. I tried to keep it as close to original df command syntax as possible. Turned out a bit complicated, but flexible and columns are perfectly aligned. Sorry for my python skills 😄

What it looks like:

/Users/amaksoft> df
Filesystem        Block size  Blocks  Used  Available  Capacity  Mounted on
/boot.py@pyboard        4096     512     3        509        1%  /pyboard/boot.py

/Users/amaksoft> df -h
Filesystem         Size    Used  Available  Capacity  Mounted on
/boot.py@pyboard  2.0Mi  12.0Ki      2.0Mi        1%  /pyboard/boot.py

/Users/amaksoft> df -H
Filesystem        Size   Used  Available  Capacity  Mounted on
/boot.py@pyboard  2.1M  12.3K       2.1M        1%  /pyboard/boot.py

/Users/amaksoft> df -b
Filesystem            Size    Used  Available  Capacity  Mounted on
/boot.py@pyboard  2097152B  12288B   2084864B        1%  /pyboard/boot.py