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.Client
is 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
sysfs
filesystem) and the udev daemon (through atmpfs
filesystem) and presented throughGUdev.Device
objects. 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.Device
objects, 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.Enumerator
type.To listen to uevents, connect to the
GUdev.Client
::uevent
signal.- classmethod new(subsystems)¶
- Parameters:
subsystems ([
str
] orNone
) – ANone
terminated string array of subsystems to listen for uevents on,None
to not listen on uevents at all, or an empty array to listen to uevents on all subsystems. See the documentation for theGUdev.Client
:subsystems
property for details on this parameter.- Returns:
A new
GUdev.Client
object. Free withGObject.Object.unref
().- Return type:
Constructs a
GUdev.Client
object that can be used to query information about devices. Connect to theGUdev.Client
::uevent
signal to listen for uevents. Note that signals are emitted in thethread-default main loop
of the thread that you call this constructor from.
- query_by_device_file(device_file)¶
- Parameters:
device_file (
str
) – A device file.- Returns:
A
GUdev.Device
object orNone
if the device was not found. Free withGObject.Object.unref
().- Return type:
GUdev.Device
orNone
Looks up a device for a device file.
- query_by_device_number(type, number)¶
- Parameters:
type (
GUdev.DeviceType
) – A value from theGUdev.DeviceType
enumeration.number (
int
) – A device number.
- Returns:
A
GUdev.Device
object orNone
if the device was not found. Free withGObject.Object.unref
().- Return type:
GUdev.Device
orNone
Looks up a device for a type and device number.
- query_by_subsystem(subsystem)¶
- Parameters:
subsystem (
str
orNone
) – The subsystem to get devices for orNone
to get all devices.- Returns:
A list of
GUdev.Device
objects. 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.Device
object orNone
if the device was not found. Free withGObject.Object.unref
().- Return type:
GUdev.Device
orNone
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.Device
object orNone
if the device was not found. Free withGObject.Object.unref
().- Return type:
GUdev.Device
orNone
Looks up a device for a sysfs path.
- do_uevent(action, device) virtual¶
- Parameters:
action (
str
) –device (
GUdev.Device
) –
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.Device
the 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 loop
of 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.