mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
storage: Use udisks to list disks and df for disk space utilization
- Fetch disk information for all disks using udisks - Call df as superuser so that all disks are listed (udisks doesn't need sudo) - Improved implementation to check if device is removable Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
1 parent
0ec1d7cbb2
commit
a2d07fef0b
3 files changed
+61
-63
No files matched your search
@@ -48,6 +48,9 @@ def parse_arguments():
|
||||
subparser = subparsers.add_parser('eject', help='Eject a storage device')
|
||||
subparser.add_argument('device', help='Path of the device to eject')
|
||||
|
||||
subparsers.add_parser('usage-info',
|
||||
help='Get information about disk space usage')
|
||||
|
||||
subparsers.required = True
|
||||
return parser.parse_args()
|
||||
|
||||
@@ -301,6 +304,15 @@ def umount_all_filesystems_of_drive(drive_object_path):
|
||||
umount_filesystem(obj.get_filesystem())
|
||||
|
||||
|
||||
def subcommand_usage_info(_):
|
||||
"""Get information about disk space usage."""
|
||||
command = [
|
||||
'df', '--exclude-type=tmpfs', '--exclude-type=devtmpfs',
|
||||
'--block-size=1', '--output=source,fstype,size,used,avail,pcent,target'
|
||||
]
|
||||
subprocess.run(command, check=True)
|
||||
|
||||
|
||||
def main():
|
||||
"""Parse arguments and perform all duties."""
|
||||
arguments = parse_arguments()
|
||||
|
||||
Reference in new issue
Block a user