GUdev.Client¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
Properties¶
Name |
Type |
Flags |
Short Description |
|---|---|---|---|
[ |
r/w/co |
The subsystems to listen for changes on |
Signals¶
- Inherited:
Name |
Short Description |
|---|---|
Emitted when client receives an uevent. |
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
|---|---|---|---|
parent |
r |
Class Details¶
- class GUdev.Client(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
GUdev.Clientis used to query information about devices on a Linux system from the Linux kernel and the udev device manager.Device information is retrieved from the kernel (through the
sysfsfilesystem) and the udev daemon (through atmpfsfilesystem) and presented throughGUdev.Deviceobjects. This means that no blocking IO ever happens (in both cases, we are essentially just reading data from kernel memory) and as such there are no asynchronous versions of the provided methods.To get
GUdev.Deviceobjects, useGUdev.Client.query_by_subsystem(),GUdev.Client.query_by_device_number(),GUdev.Client.query_by_device_file(),GUdev.Client.query_by_sysfs_path(),GUdev.Client.query_by_subsystem_and_name() or theGUdev.Enumeratortype.To listen to uevents, connect to the
GUdev.Client::ueventsignal.- classmethod new(subsystems)¶
- Parameters:
subsystems ([
str] orNone) – ANoneterminated string array of subsystems to listen for uevents on,Noneto not listen on uevents at all, or an empty array to listen to uevents on all subsystems. See the documentation for theGUdev.Client:subsystemsproperty for details on this parameter.- Returns:
A new
GUdev.Clientobject. Free withGObject.Object.unref().- Return type:
Constructs a
GUdev.Clientobject that can be used to query information about devices. Connect to theGUdev.Client::ueventsignal to listen for uevents. Note that signals are emitted in thethread-default main loopof the thread that you call this constructor from.
- query_by_device_file(device_file)¶
- Parameters:
device_file (
str) – A device file.- Returns:
A
GUdev.Deviceobject orNoneif the device was not found. Free withGObject.Object.unref().- Return type:
GUdev.DeviceorNone
Looks up a device for a device file.
- query_by_device_number(type, number)¶
- Parameters:
type (
GUdev.DeviceType) – A value from theGUdev.DeviceTypeenumeration.number (
int) – A device number.
- Returns:
A
GUdev.Deviceobject orNoneif the device was not found. Free withGObject.Object.unref().- Return type:
GUdev.DeviceorNone
Looks up a device for a type and device number.
- query_by_subsystem(subsystem)¶
- Parameters:
subsystem (
strorNone) – The subsystem to get devices for orNoneto get all devices.- Returns:
A list of
GUdev.Deviceobjects. The caller should free the result by usingGObject.Object.unref() on each element in the list and then g_list_free() on the list.- Return type:
[
GUdev.Device] orNone
Gets all devices belonging to subsystem.
- query_by_subsystem_and_name(subsystem, name)¶
- Parameters:
- Returns:
A
GUdev.Deviceobject orNoneif the device was not found. Free withGObject.Object.unref().- Return type:
GUdev.DeviceorNone
Looks up a device for a subsystem and name.
- query_by_sysfs_path(sysfs_path)¶
- Parameters:
sysfs_path (
str) – A sysfs path.- Returns:
A
GUdev.Deviceobject orNoneif the device was not found. Free withGObject.Object.unref().- Return type:
GUdev.DeviceorNone
Looks up a device for a sysfs path.
- do_uevent(action, device) virtual¶
- Parameters:
action (
str) –device (
GUdev.Device) –
Signal class handler for the
GUdev.Client::ueventsignal.
Signal Details¶
- GUdev.Client.signals.uevent(client, action, device)¶
- Signal Name:
uevent- Flags:
- Parameters:
client (
GUdev.Client) – The object which received the signalaction (
str) – The action for the uevent e.g. “add”, “remove”, “change”, “move”, “online” or “offline”device (
GUdev.Device) – Details about theGUdev.Devicethe event is for.
Emitted when client receives an uevent.
Note that while you’ll have access to all the device’s properties and attributes for the majority of actions, only the sysfs path will be available when the device is removed.
Also note that the action is an arbitrary string, controlled by device drivers. Other values than those listed is possible, but unlikely.
This signal is emitted in the
thread-default main loopof the thread that client was created in.
Property Details¶
- GUdev.Client.props.subsystems¶
- Name:
subsystems- Type:
[
str]- Default Value:
[]- Flags:
The subsystems to listen for uevents on.
To listen for only a specific DEVTYPE for a given SUBSYSTEM, use “subsystem/devtype”. For example, to only listen for uevents where SUBSYSTEM is usb and DEVTYPE is usb_interface, use “usb/usb_interface”.
If this property is
None, then no events will be reported. If it’s the empty array, events from all subsystems will be reported.