utils: add umount_all function

Add utility function to unmount any mountpoint present in the /mnt
folder.

This function is a simplified version of the legacy bash function
ogUnmountAll used in several operations.
more_events
Jose M. Guisado 2023-05-04 09:58:04 +02:00
parent 803ba74510
commit cf6f50e528
1 changed files with 9 additions and 0 deletions

View File

@ -69,6 +69,15 @@ def umount(target):
return not proc.returncode
def umount_all():
"""
Umounts all mountpoints present in the /mnt folder.
"""
for path in ['/mnt/'+child for child in os.listdir('/mnt/')]:
if os.path.ismount(path):
umount(path)
def get_usedperc(mountpoint):
"""
Returns percetage of used filesystem as decimal number.