pyudev is a LGPL licensed, pure Python binding to libudev, the device and hardware management and information library of Linux.
It exposes almost the complete libudev functionality. You can:
pyudev supports CPython 2 (2.6 or newer) and 3 (3.1 or newer), and PyPy 1.5 or newer. It is tested against udev 151 or newer. Older versions of udev as found on dated Linux systems may work, but are not officially supported.
Thanks to the power of libudev, usage of pyudev is very simple. Getting the labels of all partitions just takes a few lines:
>>> import pyudev
>>> context = pyudev.Context()
>>> for device in context.list_devices(subsystem='block', DEVTYPE='partition'):
... print(device.get('ID_FS_LABEL', 'unlabeled partition'))
...
boot
swap
system
The User guide gives an introduction into the most common operations in pyudev, a detailled reference is provided by the API documentation.
Mailing list
Questions about usage and development of pyudev can be posted to the mailing list pyudev@librelist.com, which is hosted by librelist.com. To subscribe to this list, just send a mail to pyudev@librehost.com and reply to the confirmation mail. To unsubscribe again, write to pyudev-unsubscribe@librelist.com and reply to the confirmation mail. Past discussions and questions are available in the list archives.
Issues
Issues and bugs can be reported to the issue tracker on GitHub. Please provide as much information as possible when reporting an issue. Patches addressing new or existing issues are very welcome.
The source code is hosted on GitHub:
git clone --recursive git://github.com/lunaryorn/pyudev.git
Feel free to fork the repository and send pull requests or patches. Please add unit tests for your code, if possible. The testsuite documentation gives you an overview about the pyudev testsuite.