diff options
-rwxr-xr-x | lib/isodumper.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/isodumper.py b/lib/isodumper.py index f095410..60345ed 100755 --- a/lib/isodumper.py +++ b/lib/isodumper.py @@ -156,6 +156,28 @@ class UDisks2(object): logging.debug(f"Not mounted {block['path']}") return True, "" + + def get_partitions(self, target): + # keep only the end, like sdb + target = os.path.basename(target) + partitions = [] + objects = self._udisks2_obj_manager.GetManagedObjects() + re_block = re.compile('(?P<path>.*?/block_devices/(?P<id>.*))') + blocks = [m.groupdict() for m in + [re_block.match(path) for path in (objects.keys())] + if m] + for block in blocks: + if (self.SERVICE + '.Partition' in objects[block['path']]): # we skip non partition blocks + # Table should be something like '/org/freedesktop/UDisks2/block_devices/sdb' + print(objects[block['path']][self.SERVICE + '.Block']['Device'], objects[block['path']][self.SERVICE + '.Partition']['Table'],target) + if objects[block['path']][self.SERVICE + '.Partition']['Table'].split('/')[-1] == target: + partition = objects[block['path']][self.SERVICE + '.Block'] + print(partition['IdLabel']) + partitions.append( {'device': bytes(partition['Device']).decode("UTF-8", "replace").strip("\0"), + 'label': partition['IdLabel'], + 'type': partition['IdType']}) + return partitions + def eject(self, device): ''' device is expected like /dev/sda''' block = os.path.basename(device) @@ -243,6 +265,13 @@ class IsoDumper(basedialog.BaseDialog): message = _('Target Device: {}').format(self.dev) self.logger(message) logging.info(message) + partitions = self.u.get_partitions(self.dev.split('(')[1].split(')')[0]) + #, verb in singular 3rd person + self.logger(_("Contents partition(s)")) + for partition in partitions: + self.logger(_("{device}: Type {type} Label {label}").format(device=partition['device'], + type=partition['type'], + label=partition['label'],)) self.partition_cbox.setEnabled() self.partition_cbox.setChecked(False) self.backup_cbox.setEnabled() |