diff options
author | Jose M. Guisado <jguisado@soleta.eu> | 2023-05-04 09:58:04 +0200 |
---|---|---|
committer | Jose M. Guisado <jguisado@soleta.eu> | 2023-05-09 13:09:07 +0200 |
commit | cf6f50e5284acfe0e970d1922a23b62f9241b1ca (patch) | |
tree | 878ab5c6e182b43f6fc12a7f158fe5bfc5c4fe4a | |
parent | 803ba74510df3400da4d5d02351f3858460cffda (diff) |
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.
-rw-r--r-- | src/utils/fs.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/utils/fs.py b/src/utils/fs.py index a0c12d4..49da7ce 100644 --- a/src/utils/fs.py +++ b/src/utils/fs.py @@ -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. |