Cull children since the script does not mount parents

I don't thing this is entirely correct but I have no example at hand.
You should be able to create a filesystem on e.g. /dev/sde directly without
creating a partition /dev/sde1 first. So, technically this "parent" without
"children" should be mountable.

Since the script does not consider this. This commit filters for
elements/"parents" without "children".

For most cases this will keep the height of the output smaller not to run into a
curses crash. Not ideal and the curses crashes should get looked at, but for now
this will do to reduce crashes with small windows and large amount or block
devices – thanks snap.
This commit is contained in:
Syphdias 2022-03-21 00:14:49 +01:00
parent c89d4eed56
commit a13aba5569
No known key found for this signature in database
GPG Key ID: 9362D5125478A62F

View File

@ -37,6 +37,12 @@ class ChoosePartition:
r = subprocess.check_output(['lsblk', '--all', '--json', '-O']) r = subprocess.check_output(['lsblk', '--all', '--json', '-O'])
self.blkinfo = json.loads(r) self.blkinfo = json.loads(r)
partn = 0 partn = 0
# filter for devices with children, none other are used by this script
# (this is not entirely correct, but goes beyond these lines)
self.blkinfo['blockdevices'] = [
bd
for bd in self.blkinfo['blockdevices']
if 'children' in bd]
for bd in self.blkinfo['blockdevices']: for bd in self.blkinfo['blockdevices']:
if 'children' not in bd: if 'children' not in bd:
continue continue