diff options
author | Papoteur <papoteur@mageia.org> | 2021-03-28 15:02:35 +0200 |
---|---|---|
committer | Papoteur <papoteur@mageia.org> | 2021-03-28 15:02:35 +0200 |
commit | 9049b787912dac1d9b85533ad77086fcebb505c3 (patch) | |
tree | 90762c7087674498f868e463821f4ec9b85e934f | |
parent | c2fe725a17c75409639b7dd2194a8ca2a1ae6047 (diff) | |
download | isodumper-9049b787912dac1d9b85533ad77086fcebb505c3.tar isodumper-9049b787912dac1d9b85533ad77086fcebb505c3.tar.gz isodumper-9049b787912dac1d9b85533ad77086fcebb505c3.tar.bz2 isodumper-9049b787912dac1d9b85533ad77086fcebb505c3.tar.xz isodumper-9049b787912dac1d9b85533ad77086fcebb505c3.zip |
Add reporting partitions when selecting a device.
-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() |