From 4d4f512d00f02a1952f52b61a0f4d60f3fd185e0 Mon Sep 17 00:00:00 2001 From: Omur Ozbahceliler Date: Mon, 15 Jul 2024 17:33:49 +0100 Subject: [PATCH] prints none found if there are no partitions to umount --- diskforge.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/diskforge.py b/diskforge.py index ad7f04f..4d36afb 100644 --- a/diskforge.py +++ b/diskforge.py @@ -87,6 +87,8 @@ def identify_disks(): def unmount_disks_partitions(disks): + any_unmounted = False + for disk in disks: try: partitions_output = subprocess.check_output( @@ -100,8 +102,6 @@ def unmount_disks_partitions(disks): if not partitions: continue - unmounted = False - for partition in partitions: try: mount_points = subprocess.check_output( @@ -120,12 +120,15 @@ def unmount_disks_partitions(disks): stderr=subprocess.DEVNULL ) print(f"Unmounted {mount_point}") - unmounted = True + any_unmounted = True except subprocess.CalledProcessError: pass except subprocess.CalledProcessError: - pass # outout gets too verbose if I print this one or the one above. + pass + + if not any_unmounted: + print("None Found") def verify_disk_partitions(disk):