pyudev – pure Python libudev binding

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:

  • enumerate devices, filtered by specific criteria (pyudev.Context)
  • query device information, properties and attributes,
  • monitor devices, both synchronously and asynchronously with background threads, or within the event loops of Qt (pyudev.pyqt4, pyudev.pyside), glib (pyudev.glib) and wxPython (pyudev.wx).

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.

Usage

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.

Support

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.

Development

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.

Project Versions

pyudev 0.15

Install

  • pip install pyudev

Links

Support

Table Of Contents

Next topic

User guide

This Page