def filter_by(self, subsystem, device_type=None): """ Filter incoming events. ``subsystem`` is a byte or unicode string with the name of a subsystem (e.g. ``'input'``). Only events originating from the given subsystem pass the filter and are handed to the caller. If given, ``device_type`` is a byte or unicode string specifying the device type. Only devices with the given device type are propagated to the caller. If ``device_type`` is not given, no additional filter for a specific device type is installed. These filters are executed inside the kernel, and client processes will usually not be woken up for device, that do not match these filters. .. versionchanged:: 0.15 This method can also be after :meth:`start()` now. """ subsystem = ensure_byte_string(subsystem) if device_type: device_type = ensure_byte_string(device_type) libudev.udev_monitor_filter_add_match_subsystem_devtype( self, subsystem, device_type) libudev.udev_monitor_filter_update(self)
def remove_filter(self): """ Remove any filters installed with :meth:`filter_by()` or :meth:`filter_by_tag()` from this monitor. .. warning:: Up to udev 181 (and possibly even later versions) the underlying ``udev_monitor_filter_remove()`` seems to be broken. If used with affected versions this method always raises :exc:`~exceptions.ValueError`. Raise :exc:`~exceptions.EnvironmentError` if removal of installed filters failed. .. versionadded:: 0.15 """ libudev.udev_monitor_filter_remove(self) libudev.udev_monitor_filter_update(self)
def filter_by_tag(self, tag): """ Filter incoming events by the given ``tag``. ``tag`` is a byte or unicode string with the name of a tag. Only events for devices which have this tag attached pass the filter and are handed to the caller. Like with :meth:`filter_by` this filter is also executed inside the kernel, so that client processes are usually not woken up for devices without the given ``tag``. .. udevversion:: 154 .. versionadded:: 0.9 .. versionchanged:: 0.15 This method can also be after :meth:`start()` now. """ libudev.udev_monitor_filter_add_match_tag( self, ensure_byte_string(tag)) libudev.udev_monitor_filter_update(self)
def filter_by_tag(self, tag): """ Filter incoming events by the given ``tag``. ``tag`` is a byte or unicode string with the name of a tag. Only events for devices which have this tag attached pass the filter and are handed to the caller. Like with :meth:`filter_by` this filter is also executed inside the kernel, so that client processes are usually not woken up for devices without the given ``tag``. .. udevversion:: 154 .. versionadded:: 0.9 .. versionchanged:: 0.15 This method can also be after :meth:`start()` now. """ libudev.udev_monitor_filter_add_match_tag(self, ensure_byte_string(tag)) libudev.udev_monitor_filter_update(self)