GUdev.Device¶
| Subclasses: | None |
|---|
Methods¶
| Inherited: | GObject.Object (37) |
|---|---|
| Structs: | GObject.ObjectClass (5) |
Virtual Methods¶
| Inherited: | GObject.Object (7) |
|---|
Properties¶
None
Signals¶
| Inherited: | GObject.Object (1) |
|---|
Class Details¶
-
class
GUdev.Device(**kwargs)¶ Bases: GObject.ObjectAbstract: No Structure: GUdev.DeviceClassThe
GUdev.Deviceclass is used to get information about a specific device. Note that you cannot instantiate aGUdev.Deviceobject yourself. Instead you must useGUdev.Clientto obtainGUdev.Deviceobjects.To get basic information about a device, use
GUdev.Device.get_subsystem(),GUdev.Device.get_devtype(),GUdev.Device.get_name(),GUdev.Device.get_number(),GUdev.Device.get_sysfs_path(),GUdev.Device.get_driver(),GUdev.Device.get_action(),GUdev.Device.get_seqnum(),GUdev.Device.get_device_type(),GUdev.Device.get_device_number(),GUdev.Device.get_device_file(),GUdev.Device.get_device_file_symlinks().To navigate the device tree, use
GUdev.Device.get_parent() andGUdev.Device.get_parent_with_subsystem().To access udev properties for the device, use
GUdev.Device.get_property_keys(),GUdev.Device.has_property(),GUdev.Device.get_property(),GUdev.Device.get_property_as_int(),GUdev.Device.get_property_as_uint64(),GUdev.Device.get_property_as_double(),GUdev.Device.get_property_as_boolean() andGUdev.Device.get_property_as_strv().To access sysfs attributes for the device, use
GUdev.Device.get_sysfs_attr_keys(),GUdev.Device.has_sysfs_attr(),GUdev.Device.get_sysfs_attr(),GUdev.Device.get_sysfs_attr_as_int(),GUdev.Device.get_sysfs_attr_as_uint64(),GUdev.Device.get_sysfs_attr_as_double(),GUdev.Device.get_sysfs_attr_as_boolean() andGUdev.Device.get_sysfs_attr_as_strv().Note that all getters on
GUdev.Deviceare non-reffing – returned values are owned by the object, should not be freed and are only valid as long as the object is alive.By design,
GUdev.Devicewill not react to changes for a device – it only contains a snapshot of information when theGUdev.Deviceobject was created. To work with changes, you typically connect to theGUdev.Client::ueventsignal on aGUdev.Clientand get a newGUdev.Devicewhenever an event happens.-
get_action()¶ Returns: An action string. Return type: strGets the most recent action (e.g. “add”, “remove”, “change”, etc.) for self.
-
get_device_file()¶ Returns: The device file for self or Noneif no device file exists.Return type: strorNoneGets the device file for self.
-
get_device_file_symlinks()¶ Returns: A Noneterminated string array of symlinks. This array is owned by self and should not be freed by the caller.Return type: [ str]Gets a list of symlinks (in
/dev) that points to the device file for self.
-
get_device_number()¶ Returns: The device number for self or 0 if unknown. Return type: intGets the device number, if any, for self.
-
get_device_type()¶ Returns: The device number for self or GUdev.DeviceType.NONEif the device does not have a device file.Return type: GUdev.DeviceTypeGets the type of the device file, if any, for self.
-
get_driver()¶ Returns: The name of the driver for self or Noneif unknown.Return type: strorNoneGets the name of the driver used for self.
-
get_is_initialized()¶ Returns: Whether self has been initialized. Return type: boolGets whether self has been initialized.
New in version 165.
-
get_number()¶ Returns: The number of self. Return type: strGets the number of self, e.g. “3” if
GUdev.Device.get_name() returns “sda3”.
-
get_parent()¶ Returns: A GUdev.DeviceorNoneif self has no parent. Free withGObject.Object.unref().Return type: GUdev.DeviceorNoneGets the immediate parent of self, if any.
-
get_parent_with_subsystem(subsystem, devtype)¶ Parameters: Returns: A
GUdev.DeviceorNoneif self has no parent with subsystem and devtype. Free withGObject.Object.unref().Return type: GUdev.DeviceorNoneWalks up the chain of parents of self and returns the first device encountered where subsystem and devtype matches, if any.
-
get_property(key)¶ Parameters: key ( str) – Name of property.Returns: The value for key or Noneif key doesn’t exist on self. Do not free this string, it is owned by self.Return type: strorNoneLook up the value for key on self.
-
get_property_as_boolean(key)¶ Parameters: key ( str) – Name of property.Returns: The value for key or Falseif key doesn’t exist or isn’t abool.Return type: boolLook up the value for key on self and convert it to an boolean. This is done by doing a case-insensitive string comparison on the string value against “1” and “true”.
-
get_property_as_double(key)¶ Parameters: key ( str) – Name of property.Returns: The value for key or 0.0 if key doesn’t exist or isn’t a float.Return type: floatLook up the value for key on self and convert it to a double precision floating point number using strtod().
-
get_property_as_int(key)¶ Parameters: key ( str) – Name of property.Returns: The value for key or 0 if key doesn’t exist or isn’t an integer. Return type: intLook up the value for key on self and convert it to an integer using strtol().
-
get_property_as_strv(key)¶ Parameters: key ( str) – Name of property.Returns: The value of key on self split into tokens or Noneif key doesn’t exist. This array is owned by self and should not be freed by the caller.Return type: [ str] orNoneLook up the value for key on self and return the result of splitting it into non-empty tokens split at white space (only space (’ ‘), form-feed (‘\f’), newline (‘\n’), carriage return (‘\r’), horizontal tab (‘\t’), and vertical tab (‘\v’) are considered; the locale is not taken into account).
-
get_property_as_uint64(key)¶ Parameters: key ( str) – Name of property.Returns: The value for key or 0 if key doesn’t exist or isn’t a #guint64. Return type: intLook up the value for key on self and convert it to an unsigned 64-bit integer using
GLib.ascii_strtoull().
-
get_property_keys()¶ Returns: A Noneterminated string array of property keys. This array is owned by self and should not be freed by the caller.Return type: [ str]Gets all keys for properties on self.
-
get_seqnum()¶ Returns: A sequence number. Return type: intGets the most recent sequence number for self.
-
get_sysfs_attr(name)¶ Parameters: name ( str) – Name of the sysfs attribute.Returns: The value of the sysfs attribute or Noneif there is no such attribute. Do not free this string, it is owned by self.Return type: strorNoneLook up the sysfs attribute with name on self. The retrieved value is cached in the device. Repeated calls will return the same value and not open the attribute again, unless updated through one of the “uncached” functions.
-
get_sysfs_attr_as_boolean(name)¶ Parameters: name ( str) – Name of the sysfs attribute.Returns: The value of the sysfs attribute or Falseif there is no such attribute.Return type: boolLook up the sysfs attribute with name on self and convert it to an boolean. This is done by doing a case-insensitive string comparison on the string value against “1” and “true”. The retrieved value is cached in the device. Repeated calls will return the same value and not open the attribute again, unless updated through one of the “uncached” functions.
-
get_sysfs_attr_as_boolean_uncached(name)¶ Parameters: name ( str) – Name of the sysfs attribute.Returns: The value of the sysfs attribute or Falseif there is no such attribute.Return type: boolLook up the sysfs attribute with name on self and convert it to an boolean. This is done by doing a case-insensitive string comparison on the string value against “1” and “true”. This function does blocking I/O, and updates the sysfs attributes cache.
-
get_sysfs_attr_as_double(name)¶ Parameters: name ( str) – Name of the sysfs attribute.Returns: The value of the sysfs attribute or 0.0 if there is no such attribute. Return type: floatLook up the sysfs attribute with name on self and convert it to a double precision floating point number using strtod(). The retrieved value is cached in the device. Repeated calls will return the same value and not open the attribute again, unless updated through one of the “uncached” functions.
-
get_sysfs_attr_as_double_uncached(name)¶ Parameters: name ( str) – Name of the sysfs attribute.Returns: The value of the sysfs attribute or 0.0 if there is no such attribute. Return type: floatLook up the sysfs attribute with name on self and convert it to a double precision floating point number using strtod(). This function does blocking I/O, and updates the sysfs attributes cache.
-
get_sysfs_attr_as_int(name)¶ Parameters: name ( str) – Name of the sysfs attribute.Returns: The value of the sysfs attribute or 0 if there is no such attribute. Return type: intLook up the sysfs attribute with name on self and convert it to an integer using strtol(). The retrieved value is cached in the device. Repeated calls will return the same value and not open the attribute again, unless updated through one of the “uncached” functions.
-
get_sysfs_attr_as_int_uncached(name)¶ Parameters: name ( str) – Name of the sysfs attribute.Returns: The value of the sysfs attribute or 0 if there is no such attribute. Return type: intLook up the sysfs attribute with name on self and convert it to an integer using strtol(). This function does blocking I/O, and updates the sysfs attributes cache.
-
get_sysfs_attr_as_strv(name)¶ Parameters: name ( str) – Name of the sysfs attribute.Returns: The value of the sysfs attribute split into tokens or Noneif there is no such attribute. This array is owned by self and should not be freed by the caller.Return type: [ str] orNoneLook up the sysfs attribute with name on self and return the result of splitting it into non-empty tokens split at white space (only space (’ ‘), form-feed (‘\f’), newline (‘\n’), carriage return (‘\r’), horizontal tab (‘\t’), and vertical tab (‘\v’) are considered; the locale is not taken into account).
The retrieved value is cached in the device. Repeated calls will return the same value and not open the attribute again, unless updated through one of the “uncached” functions.
-
get_sysfs_attr_as_strv_uncached(name)¶ Parameters: name ( str) – Name of the sysfs attribute.Returns: The value of the sysfs attribute split into tokens or Noneif there is no such attribute. This array is owned by self and should not be freed by the caller.Return type: [ str] orNoneLook up the sysfs attribute with name on self and return the result of splitting it into non-empty tokens split at white space (only space (’ ‘), form-feed (‘\f’), newline (‘\n’), carriage return (‘\r’), horizontal tab (‘\t’), and vertical tab (‘\v’) are considered; the locale is not taken into account).
This function does blocking I/O, and updates the sysfs attributes cache.
-
get_sysfs_attr_as_uint64(name)¶ Parameters: name ( str) – Name of the sysfs attribute.Returns: The value of the sysfs attribute or 0 if there is no such attribute. Return type: intLook up the sysfs attribute with name on self and convert it to an unsigned 64-bit integer using
GLib.ascii_strtoull(). The retrieved value is cached in the device. Repeated calls will return the same value and not open the attribute again, unless updated through one of the “uncached” functions.
-
get_sysfs_attr_as_uint64_uncached(name)¶ Parameters: name ( str) – Name of the sysfs attribute.Returns: The value of the sysfs attribute or 0 if there is no such attribute. Return type: intLook up the sysfs attribute with name on self and convert it to an unsigned 64-bit integer using
GLib.ascii_strtoull(). This function does blocking I/O, and updates the sysfs attributes cache.
-
get_sysfs_attr_keys()¶ Returns: A Noneterminated string array of sysfs attribute keys. This array is owned by self and should not be freed by the caller.Return type: [ str]Gets all keys for sysfs attributes on self.
-
get_sysfs_attr_uncached(name)¶ Parameters: name ( str) – Name of the sysfs attribute.Returns: The value of the sysfs attribute or Noneif there is no such attribute. Do not free this string, it is owned by self.Return type: strorNoneLook up the sysfs attribute with name on self. This function does blocking I/O, and updates the sysfs attributes cache.
Returns: A Noneterminated string array of tags. This array is owned by self and should not be freed by the caller.Return type: [ str]Gets all tags for self.
New in version 165.
-
get_usec_since_initialized()¶ Returns: Number of micro-seconds since self was initialized or 0 if unknown. Return type: intGets number of micro-seconds since self was initialized.
This only works for devices with properties in the udev database. All other devices return 0.
New in version 165.
-
has_property(key)¶ Parameters: key ( str) – Name of property.Returns: Trueonly if the value for key exist.Return type: boolCheck if a the property with the given key exists.
-
has_sysfs_attr(key)¶ Parameters: key ( str) – Name of sysfs attribute.Returns: Trueonly if the value for key exist.Return type: boolCheck if a the sysfs attribute with the given key exists. The retrieved value is cached in the device. Repeated calls will return the same result and not check for the presence of the attribute again, unless updated through one of the “uncached” functions.
-
has_sysfs_attr_uncached(key)¶ Parameters: key ( str) – Name of sysfs attribute.Returns: Trueonly if the value for key exist.Return type: boolCheck if a the sysfs attribute with the given key exists. The retrieved value is cached in the device. Repeated calls will return the same result and not check for the presence of the attribute again, unless updated through one of the “uncached” functions.
-