aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xlib/isodumper.py67
1 files changed, 46 insertions, 21 deletions
diff --git a/lib/isodumper.py b/lib/isodumper.py
index 5ae5af3..eab8b5d 100755
--- a/lib/isodumper.py
+++ b/lib/isodumper.py
@@ -79,24 +79,44 @@ class UDisks2(object):
if m]
list=[]
- for dev in devs:
- dev_obj =objects[dev['path']][self.DRIVE]
- if (dev_obj['ConnectionBus'] == 'usb' or dev_obj['ConnectionBus'] == 'sdio') and \
- (dev_obj['Removable'] == 1 or dev_obj['MediaRemovable'] == 1 ):
- item=[]
- vend = dev_obj['Vendor']
- name = dev_obj['Model']
- for block in blocks:
- if dev['path'] == objects[block['path']][self.BLOCK]['Drive']:
- dev_name = block['path'].split('/')[-1]
- path = ''.join([i for i in dev_name if not i.isdigit()])
- path = '/dev/' + path
- break
- size = dev_obj['Size']
- item.append(vend+" "+name)
- item.append(path)
- item.append(size)
- list.append(item)
+ for block in blocks:
+ if not block['path'][-1].isdigit():
+ for dev in devs:
+ if dev['path'] == objects[block['path']][self.BLOCK]['Drive']:
+ dev_obj =objects[dev['path']][self.DRIVE]
+ if (dev_obj['ConnectionBus'] == 'usb' or dev_obj['ConnectionBus'] == 'sdio') and \
+ (dev_obj['Removable'] == 1 or dev_obj['MediaRemovable'] == 1 ):
+ item=[]
+ vend = dev_obj['Vendor']
+ if vend == "":
+ name = dev_obj['Model']
+ else:
+ name = vend + " "+ dev_obj['Model']
+ dev_name = block['path'].split('/')[-1]
+ path = '/dev/'+block['path'].split('/')[-1]
+ size = dev_obj['Size']
+ item.append(name)
+ item.append(path)
+ item.append(size)
+ list.append(item)
+ #for dev in devs:
+ #dev_obj =objects[dev['path']][self.DRIVE]
+ #if (dev_obj['ConnectionBus'] == 'usb' or dev_obj['ConnectionBus'] == 'sdio') and \
+ #(dev_obj['Removable'] == 1 or dev_obj['MediaRemovable'] == 1 ):
+ #item=[]
+ #vend = dev_obj['Vendor']
+ #name = dev_obj['Model']
+ #for block in blocks:
+ #if dev['path'] == objects[block['path']][self.BLOCK]['Drive']:
+ #dev_name = block['path'].split('/')[-1]
+ #path = ''.join([i for i in dev_name if not i.isdigit()])
+ #path = '/dev/' + path
+ #break
+ #size = dev_obj['Size']
+ #item.append(vend+" "+name)
+ #item.append(path)
+ #item.append(size)
+ #
return list
class Info(object):
@@ -122,9 +142,7 @@ class IsoDumper(object):
if len(self.list)>0:
for name, path, size in self.list:
if size != 0 :
- # convert in Mbytes
- sizeM=str(int(size)/(1024*1024))
- self.devicelist.addItem(str(name+' ('+path.lstrip()+') '+sizeM+_('Mb')),False)
+ self.devicelist.addItem(str(name+' ('+path.lstrip()+') ' + self.sizeof_fmt(size)),False)
return True
@@ -151,6 +169,13 @@ class IsoDumper(object):
self.backup_select.setEnabled()
break
+ def sizeof_fmt(self, num):
+ for unit in [_('B'),_('KiB'),_('MiB'),_('GiB'),_('TiB')]:
+ if abs(num) < 1024.0:
+ return "%3.3f %s" % (num, unit)
+ num /= 1024.0
+ return "%.1f %s" % (num, _('TiB'))
+
def backup_choosed(self):
# Add .img if not specified
if not self.backup_img_name.lower().endswith('.img'):