Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set partition name #65

Open
johnnybubonic opened this issue Oct 10, 2019 · 2 comments
Open

Cannot set partition name #65

johnnybubonic opened this issue Oct 10, 2019 · 2 comments
Assignees

Comments

@johnnybubonic
Copy link

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
@johnnybubonic
Copy link
Author

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.

@dcantrell
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants