From fb45e4177862b407e45753d0390bbcd1eb0278b9 Mon Sep 17 00:00:00 2001 From: Papoteur Date: Fri, 1 Jan 2021 21:57:34 +0100 Subject: Manage error when partition is busy and trying to unmount --- lib/isodumper.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/isodumper.py b/lib/isodumper.py index 4c3fa6b..f164547 100755 --- a/lib/isodumper.py +++ b/lib/isodumper.py @@ -127,7 +127,13 @@ class UDisks2(object): iface = self.bus.get(self.SERVICE, path_to_encrypted) fs = iface[self.SERVICE + '.Filesystem'] if fs.MountPoints: # partition is mounted - fs.Unmount({}) + try: + fs.Unmount({}) + except GLib.GError as e: + print(str(e)) + return False, _("A partition is busy. Try to free it before starting again.") + except: + raise Exception(str(e)) iface = self.bus.get(self.SERVICE, block['path']) fs = iface[self.SERVICE + '.Encrypted'] fs.Lock({}) @@ -138,7 +144,13 @@ class UDisks2(object): fs = iface[self.SERVICE + '.Filesystem'] if fs.MountPoints: # partition is mounted logging.debug(f"Unmounting {block['path']}") - fs.Unmount({}) + try: + fs.Unmount({}) + except GLib.GError as e: + print(str(e)) + return False, _("A partition is busy. Try to free it before starting again.") + except: + raise Exception(str(e)) else: logging.debug(f"Not mounted {block['path']}") return True, "" -- cgit v1.2.1