Functions

  build_history_report_json (devices)
  build_machine_id (salt)
  build_user_agent (package_name, package_version)
  checksum_format_for_display (checksum)
  checksum_get_best (checksums)
  checksum_get_by_kind (checksums, kind)
  checksum_guess_kind (checksum)
  error_from_string (error)
  error_quark ()
  error_to_string (error)
  get_os_release ()
  guid_from_string (guidstr, guid, flags)
  guid_hash_data (data, datasz, flags)
  guid_hash_string (str)
  guid_is_valid (guid)
  guid_to_string (guid, flags)
  keyring_kind_from_string (keyring_kind)
  keyring_kind_to_string (keyring_kind)
  status_from_string (status)
  status_to_string (status)
  trust_flag_from_string (trust_flag)
  trust_flag_to_string (trust_flag)
  update_state_from_string (update_state)
  update_state_to_string (update_state)
  version_format_from_string (str)
  version_format_to_string (kind)

Details

Fwupd.build_history_report_json(devices)[source]
Parameters:devices ([Fwupd.Device]) – devices
Raises:GLib.Error
Returns:a string, or None if the ID is not present
Return type:str

Builds a JSON report for the list of devices. No filtering is done on the devices array, and it is expected that the caller will filter to something sane, e.g. Fwupd.DEVICE_FLAG_REPORTED at the bare minimum.

New in version 1.0.4.

Fwupd.build_machine_id(salt)[source]
Parameters:salt (str) – The salt, or None for none
Raises:GLib.Error
Returns:the SHA256 machine hash, or None if the ID is not present
Return type:str

Gets a salted hash of the /etc/machine-id contents. This can be used to identify a specific machine. It is not possible to recover the original machine-id from the machine-hash.

New in version 1.0.4.

Fwupd.build_user_agent(package_name, package_version)[source]
Parameters:
  • package_name (str) – client program name, e.g. “gnome-software”
  • package_version (str) – client program version, e.g. “3.28.1”
Returns:

a string, e.g. foo/0.1 (Linux i386 4.14.5; en; Fedora 27) fwupd/1.0.3

Return type:

str

Builds a user-agent to use for the download.

Supplying harmless details to the server means it knows more about each client. This allows the web service to respond in a different way, for instance sending a different metadata file for old versions of fwupd, or returning an error for Solaris machines.

Before freaking out about theoretical privacy implications, much more data than this is sent to each and every website you visit.

New in version 1.0.3.

Fwupd.checksum_format_for_display(checksum)[source]
Parameters:checksum (str) – A checksum
Returns:text, or None for invalid
Return type:str

Formats a checksum for display.

New in version 0.9.3.

Fwupd.checksum_get_best(checksums)[source]
Parameters:checksums ([str]) – checksums
Returns:a checksum from the array, or None if nothing was suitable
Return type:str

Gets a the best possible checksum kind.

New in version 0.9.4.

Fwupd.checksum_get_by_kind(checksums, kind)[source]
Parameters:
Returns:

a checksum from the array, or None if not found

Return type:

str

Gets a specific checksum kind.

New in version 0.9.4.

Fwupd.checksum_guess_kind(checksum)[source]
Parameters:checksum (str) – A checksum
Returns:a GLib.ChecksumType, e.g. GLib.ChecksumType.SHA1
Return type:GLib.ChecksumType

Guesses the checksum kind based on the length of the hash.

New in version 0.9.3.

Fwupd.error_from_string(error)[source]
Parameters:error (str) – A string, e.g. org.freedesktop.fwupd.VersionNewer
Returns:enumerated value
Return type:Fwupd.Error

Converts a string to a Fwupd.Error.

New in version 0.7.0.

Fwupd.error_quark()[source]
Returns:An error quark.
Return type:int

New in version 0.1.1.

Fwupd.error_to_string(error)[source]
Parameters:error (Fwupd.Error) – A Fwupd.Error, e.g. Fwupd.Error.VERSION_NEWER
Returns:identifier string
Return type:str

Converts a Fwupd.Error to a string.

New in version 0.7.0.

Fwupd.get_os_release()[source]
Raises:GLib.Error
Returns:keys from os-release
Return type:{str: str}

Loads information from the system os-release file.

New in version 1.0.7.

Fwupd.guid_from_string(guidstr, guid, flags)[source]
Parameters:
Raises:

GLib.Error

Returns:

True for success

Return type:

bool

Converts a string GUID into its binary encoding. All string GUIDs are formatted as big endian but on-disk can be encoded in different ways.

New in version 1.2.5.

Fwupd.guid_hash_data(data, datasz, flags)[source]
Parameters:
Returns:

A new GUID, or None for internal error

Return type:

str

Returns a GUID for some data. This uses a hash and so even small differences in the data will produce radically different return values.

The implementation is taken from RFC4122, Section 4.1.3; specifically using a type-5 SHA-1 hash.

New in version 1.2.5.

Fwupd.guid_hash_string(str)[source]
Parameters:str (str) – A source string to use as a key
Returns:A new GUID, or None if the string was invalid
Return type:str

Returns a GUID for a given string. This uses a hash and so even small differences in the str will produce radically different return values.

The default implementation is taken from RFC4122, Section 4.1.3; specifically using a type-5 SHA-1 hash with a DNS namespace. The same result can be obtained with this simple python program:

#!/usr/bin/python import uuid print uuid.uuid5(uuid.NAMESPACE_DNS, ‘python.org’)

New in version 1.2.5.

Fwupd.guid_is_valid(guid)[source]
Parameters:guid (str) – string to check, e.g. 00112233-4455-6677-8899-aabbccddeeff
Returns:True if guid was a valid GUID, False otherwise
Return type:bool

Checks the string is a valid GUID.

New in version 1.2.5.

Fwupd.guid_to_string(guid, flags)[source]
Parameters:
Returns:

A new GUID

Return type:

str

Returns a text GUID of mixed or BE endian for a packed buffer.

New in version 1.2.5.

Fwupd.keyring_kind_from_string(keyring_kind)[source]
Parameters:keyring_kind (str) – a string, e.g. gpg
Returns:a Fwupd.KeyringKind, e.g. Fwupd.KeyringKind.GPG
Return type:Fwupd.KeyringKind

Converts an printable string to an enumerated type.

New in version 0.9.7.

Fwupd.keyring_kind_to_string(keyring_kind)[source]
Parameters:keyring_kind (Fwupd.KeyringKind) – a Fwupd.KeyringKind, e.g. Fwupd.KeyringKind.GPG
Returns:a string, e.g. gpg
Return type:str

Converts an enumerated type to a printable string.

New in version 0.9.7.

Fwupd.status_from_string(status)[source]
Parameters:status (str) – A string, e.g. decompressing
Returns:enumerated value
Return type:Fwupd.Status

Converts a string to a Fwupd.Status.

New in version 0.1.1.

Fwupd.status_to_string(status)[source]
Parameters:status (Fwupd.Status) – A Fwupd.Status, e.g. Fwupd.Status.DECOMPRESSING
Returns:identifier string
Return type:str

Converts a Fwupd.Status to a string.

New in version 0.1.1.

Fwupd.trust_flag_from_string(trust_flag)[source]
Parameters:trust_flag (str) – A string, e.g. payload
Returns:enumerated value
Return type:Fwupd.TrustFlags

Converts a string to a Fwupd.TrustFlags.

New in version 0.7.0.

Fwupd.trust_flag_to_string(trust_flag)[source]
Parameters:trust_flag (Fwupd.TrustFlags) – A Fwupd.TrustFlags, e.g. Fwupd.TrustFlags.PAYLOAD
Returns:identifier string
Return type:str

Converts a Fwupd.TrustFlags to a string.

New in version 0.7.0.

Fwupd.update_state_from_string(update_state)[source]
Parameters:update_state (str) – A string, e.g. pending
Returns:enumerated value
Return type:Fwupd.UpdateState

Converts a string to a Fwupd.UpdateState.

New in version 0.7.0.

Fwupd.update_state_to_string(update_state)[source]
Parameters:update_state (Fwupd.UpdateState) – A Fwupd.UpdateState, e.g. Fwupd.UpdateState.PENDING
Returns:identifier string
Return type:str

Converts a Fwupd.UpdateState to a string.

New in version 0.7.0.

Fwupd.version_format_from_string(str)[source]
Parameters:str (str) – A string, e.g. quad
Returns:A Fwupd.VersionFormat, e.g. Fwupd.VersionFormat.TRIPLET
Return type:Fwupd.VersionFormat

Converts text to a display version type.

New in version 1.2.9.

Fwupd.version_format_to_string(kind)[source]
Parameters:kind (Fwupd.VersionFormat) – A Fwupd.VersionFormat, e.g. Fwupd.VersionFormat.TRIPLET
Returns:A string, e.g. quad, or None if not known
Return type:str

Converts a display version type to text.

New in version 1.2.9.