pyparted
pyparted copied to clipboard
Cannot set partition name
This seems to break, at least in python 3.7. I get AttributeError: can't set attribute:
Python 3.7.4 (default, Jul 16 2019, 07:12:58)
[GCC 9.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import parted
>>> dev = parted.getDevice('/dev/vdb')
>>> disk = parted.Disk(dev)
>>> part = disk.partitions[0]
>>> part.name = 'foo'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: can't set attribute
[root@test ~]# fdisk -l /dev/vdb
Disk /dev/vdb: 20 GiB, 21474836480 bytes, 41943040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 5FCC195B-9A79-4636-B66A-83DC9B44CE99
Device Start End Sectors Size Type
/dev/vdb1 2048 41940991 41938944 20G Linux filesystem
Worth noting that the following works and sets the name:
Python 3.7.4 (default, Jul 16 2019, 07:12:58)
[GCC 9.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import parted
>>> dev = parted.getDevice('/dev/vdb')
>>> disk = parted.Disk(dev)
>>> part = disk.partitions[0]
>>> p = part.getPedPartition()
>>> p.set_name('foo')
but I presume this is not desired, as it seems PedPartitions are intended for internal library-use only.
That's true. Anything with Ped in the name is mapping down to libparted. The whole point of pyparted is to have a slightly higher level API for working with libparted.
Things like getPedPartion() exist because I need to pass those around among libparted calls. I'll look in to this one more tomorrow when I get a chance. Thanks.