diff options
author | papoteur-mga <yves.brungard_git@gadz.org> | 2013-10-13 16:53:01 +0200 |
---|---|---|
committer | papoteur-mga <yves.brungard_git@gadz.org> | 2013-10-13 16:53:01 +0200 |
commit | d121c7409f14ca8bf6259ecf1bf3e4ed44ac080a (patch) | |
tree | 2f7aed47fd6a3807a9cab9f6dbf29495e14de0b3 /lib | |
parent | ff90c569069867f998d68eb09ccebf33d4d7de49 (diff) | |
download | isodumper-d121c7409f14ca8bf6259ecf1bf3e4ed44ac080a.tar isodumper-d121c7409f14ca8bf6259ecf1bf3e4ed44ac080a.tar.gz isodumper-d121c7409f14ca8bf6259ecf1bf3e4ed44ac080a.tar.bz2 isodumper-d121c7409f14ca8bf6259ecf1bf3e4ed44ac080a.tar.xz isodumper-d121c7409f14ca8bf6259ecf1bf3e4ed44ac080a.zip |
Add a test for the size of the device. Exit if the size is too small
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/find_devices | 3 | ||||
-rwxr-xr-x | lib/isodumper.py | 37 |
2 files changed, 27 insertions, 13 deletions
diff --git a/lib/find_devices b/lib/find_devices index 6a56c03..0b32eac 100755 --- a/lib/find_devices +++ b/lib/find_devices @@ -17,4 +17,5 @@ for dev in devs: path = str(dev.Get('', 'DeviceFile')) vend = str(dev.Get('', 'DriveVendor')) model = str(dev.Get('', 'DriveModel')) - print vend + ' ' + model + ', ' +path + size = str(dev.Get('', 'DeviceSize')) + print vend + ' ' + model + ', ' +path+', ' + size diff --git a/lib/isodumper.py b/lib/isodumper.py index 7f22916..3d6e814 100755 --- a/lib/isodumper.py +++ b/lib/isodumper.py @@ -54,6 +54,9 @@ class IsoDumper: #eventbox.modify_bg(gtk.STATE_NORMAL, bgcol) self.log = self.logview.get_buffer() self.ddpid = 0 + + # define size of the selected device + self.deviceSize=0 # set default file filter to *.img # Added for Mageia : *.iso @@ -92,8 +95,11 @@ class IsoDumper: self.combo = self.wTree.get_widget("device_combobox") list = list.strip().split('\n') for item in list: - name,path = item.split(',') - self.combo.append_text(name+' ('+path.lstrip()+')') + name,path,size = item.split(',') + self.deviceSize=size + # convert in Mbytes + sizeM=str(int(size)/(1024*1024)) + self.combo.append_text(name+' ('+path.lstrip()+') '+sizeM+_('Mb')) dialog.destroy() def device_selected(self, widget): @@ -112,17 +118,24 @@ class IsoDumper: dialog = self.wTree.get_widget("confirm_dialog") self.logger(_('Image: ')+source) self.logger(_('Target Device: ')+self.dev) - resp = dialog.run() - if resp: - self.do_umount(target) - dialog.hide() - task = self.raw_write(source, target) - gobject.idle_add(task.next) - while gtk.events_pending(): - gtk.main_iteration(True) - + self.logger(self.deviceSize) + b = os.path.getsize(source) + self.logger(str(b)) + if b >= (eval(self.deviceSize)) : + self.logger(_('The device is too small to contain the ISO file.')) + self.emergency() else: - self.close('dummy') + resp = dialog.run() + if resp: + self.do_umount(target) + dialog.hide() + task = self.raw_write(source, target) + gobject.idle_add(task.next) + while gtk.events_pending(): + gtk.main_iteration(True) + + else: + self.close('dummy') def do_umount(self, target): mounts = self.get_mounted(target) |