From ebb2d8e4f763dfaac8b2c13ca0fce5880ed4f3d8 Mon Sep 17 00:00:00 2001 From: Papoteur Date: Thu, 8 Oct 2015 22:32:37 +0200 Subject: Better management of device busy --- lib/isodumper.py | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/isodumper.py b/lib/isodumper.py index 6dd3647..23a84d2 100644 --- a/lib/isodumper.py +++ b/lib/isodumper.py @@ -155,11 +155,6 @@ class UDisks2(object): list.append(item) return list - def unmount(self, device_node_path): - d = self.device(device_node_path) - d.Unmount({'force':False, 'auth.no_user_interaction':True}, - dbus_interface=self.FILESYSTEM) - def drive_for_device(self, device): drive = device.Get(self.BLOCK, 'Drive', dbus_interface='org.freedesktop.DBus.Properties') @@ -338,14 +333,17 @@ class IsoDumper(object): self.ima.setDisabled() self.writebt.setDisabled() self.do_umount(target) - # Writing step - #Dump mode - self.returncode=0 - b=os.path.getsize(source) - self.raw_write(source, target, b) - self.check_write(target, b) - if self.returncode == 0: - self.success() + if self.returncode != 1: + # Writing step + #Dump mode + self.returncode=0 + b=os.path.getsize(source) + self.raw_write(source, target, b) + self.check_write(target, b) + if self.returncode == 0: + self.success() + else: + self.restore() else: self.restore() def do_umount(self, target): @@ -355,16 +353,18 @@ class IsoDumper(object): for mount in mounts: self.logger(_('Trying to unmount ')+mount[0]+'...') try: - #retcode = call('umount '+mount[0], shell=True) - retcode = self.u.unmount(mount[0]) - if retcode < 0: + retcode = call('umount '+mount[0], shell=True) + if retcode == 32: + message = _('Partition %s is busy')%mount[0] + self.logger(message) + self.emergency(message) + elif retcode< 0: message = _('Error, umount ')+mount[0]+_(' was terminated by signal ')+str(retcode) self.logger(message) self.emergency(message) - else: - if retcode == 0: + elif retcode == 0: self.logger(mount[0]+_(' successfully unmounted')) - else: + else: message = _('Error, umount ')+mount[0]+_(' returned ')+str(retcode) self.logger(message) self.emergency(message) @@ -396,7 +396,7 @@ class IsoDumper(object): try: ofc= io.open(target, 'wb',0) except: - message = _('You have not the rights for writing on the device') + message = _('You have not the rights for writing on the device') +" "+ target self.logger(message) self.emergency(message) self.close() -- cgit v1.2.1