UDisks.Client

g GObject.GInterface GObject.GInterface Gio.AsyncInitable Gio.AsyncInitable GObject.GInterface->Gio.AsyncInitable Gio.Initable Gio.Initable GObject.GInterface->Gio.Initable GObject.Object GObject.Object UDisks.Client UDisks.Client GObject.Object->UDisks.Client Gio.AsyncInitable->UDisks.Client Gio.Initable->UDisks.Client

Subclasses:

None

Methods

Inherited:

GObject.Object (37), Gio.AsyncInitable (4), Gio.Initable (2)

Structs:

GObject.ObjectClass (5)

class

get_job_description_from_operation (operation)

class

new (cancellable, callback, *user_data)

class

new_finish (res)

class

new_for_connection (connection, cancellable, callback, *user_data)

class

new_for_connection_finish (res)

class

new_sync (cancellable)

get_all_blocks_for_mdraid (raid)

get_block_for_dev (block_device_number)

get_block_for_drive (drive, get_physical)

get_block_for_label (label)

get_block_for_mdraid (raid)

get_block_for_uuid (uuid)

get_cleartext_block (block)

get_drive_for_block (block)

get_drive_info (drive)

get_drive_siblings (drive)

get_id_for_display (usage, type, version, long_string)

get_job_description (job)

get_jobs_for_object (object)

get_loop_for_block (block)

get_manager ()

get_mdraid_for_block (block)

get_media_compat_for_display (media_compat)

get_members_for_mdraid (raid)

get_object (object_path)

get_object_info (object)

get_object_manager ()

get_partition_info (partition)

get_partition_table (partition)

get_partition_table_subtype_for_display (partition_table_type, partition_table_subtype)

get_partition_table_subtypes (partition_table_type)

get_partition_table_type_for_display (partition_table_type)

get_partition_type_and_subtype_for_display (partition_table_type, partition_table_subtype, partition_type)

get_partition_type_for_display (partition_table_type, partition_type)

get_partition_type_infos (partition_table_type, partition_table_subtype)

get_partitions (table)

get_size_for_display (size, use_pow2, long_string)

peek_object (object_path)

queue_changed ()

settle ()

Virtual Methods

Inherited:

GObject.Object (7), Gio.AsyncInitable (2), Gio.Initable (1)

Properties

Name

Type

Flags

Short Description

bus-connection

Gio.DBusConnection

r/w/co

The D-Bus connection with which to talk to udisksd

manager

UDisks.Manager

r

The UDisks.Manager

object-manager

Gio.DBusObjectManager

r

The Gio.DBusObjectManager used by the UDisks.Client

Signals

Inherited:

GObject.Object (1)

Name

Short Description

changed

This signal is emitted either when an object or interface is added or removed a when property has changed.

Fields

Inherited:

GObject.Object (1)

Class Details

class UDisks.Client(**kwargs)
Bases:

GObject.Object, Gio.AsyncInitable, Gio.Initable

Abstract:

No

UDisks.Client is used for accessing the UDisks service from a client program.

classmethod get_job_description_from_operation(operation)
Parameters:

operation (str) – A job operation name.

Returns:

A string that should be freed with GLib.free().

Return type:

str

Gets a human-readable and localized text string describing a a job operation.

For known job operation types, see the documentation for the

Job:Operation D-Bus property.

classmethod new(cancellable, callback, *user_data)
Parameters:

Asynchronously gets a UDisks.Client. When the operation is finished, callback will be invoked in the thread-default main loop of the thread you are calling this method from.

classmethod new_finish(res)
Parameters:

res (Gio.AsyncResult) – A Gio.AsyncResult.

Raises:

GLib.Error

Returns:

A UDisks.Client or None if error is set. Free with GObject.Object.unref() when done with it.

Return type:

UDisks.Client

Finishes an operation started with UDisks.Client.new().

classmethod new_for_connection(connection, cancellable, callback, *user_data)
Parameters:

Like UDisks.Client.new() but takes a Gio.DBusConnection which will be used when connecting to the UDisks daemon over D-Bus. This is useful for unit tests which may want to use Gio.TestDBus to create a D-Bus daemon on the session bus.

New in version 2.9.0.

classmethod new_for_connection_finish(res)
Parameters:

res (Gio.AsyncResult) – A Gio.AsyncResult.

Raises:

GLib.Error

Returns:

A UDisks.Client or None if error is set. Free with GObject.Object.unref() when done with it.

Return type:

UDisks.Client

Finishes an operation started with UDisks.Client.new_for_connection().

New in version 2.9.0.

classmethod new_sync(cancellable)
Parameters:

cancellable (Gio.Cancellable or None) – A Gio.Cancellable or None.

Raises:

GLib.Error

Returns:

A UDisks.Client or None if error is set. Free with GObject.Object.unref() when done with it.

Return type:

UDisks.Client

Synchronously gets a UDisks.Client for the local system.

get_all_blocks_for_mdraid(raid)
Parameters:

raid (UDisks.MDRaid) – A UDisks.MDRaid.

Returns:

A list of UDisks.Block instances. The returned list should be freed with g_list_free() after each element has been freed with GObject.Object.unref().

Return type:

[UDisks.Block]

Gets all RAID devices (e.g. /dev/md0 and /dev/md1) for raid.

This is usually only useful in split-brain situations — see UDisks.Client.get_block_for_mdraid() for an example — and is normally used only to convey the problem in an user interface.

New in version 2.1.

get_block_for_dev(block_device_number)
Parameters:

block_device_number (int) – A #dev_t to get a UDisks.Block for.

Returns:

A UDisks.Block or None if not found.

Return type:

UDisks.Block

Gets the UDisks.Block corresponding to block_device_number, if any.

get_block_for_drive(drive, get_physical)
Parameters:
Returns:

A UDisks.Block or None if the requested kind of block device is not available - use GObject.Object.unref() to free the returned object.

Return type:

UDisks.Block

Gets a block device corresponding to drive. The returned block device, if any, is for the whole disk drive, e.g. a partition block device is never returned.

Set get_physical to True if you need a block device that you can send low-level SCSI commands with (for multipath, this returns one of the physical paths). Set it to False if you need a block device that you can read/write data with (for multipath, this returns the mapped device).

get_block_for_label(label)
Parameters:

label (str) – The label.

Returns:

A list of UDisks.Block instances. The returned list should be freed with g_list_free() after each element has been freed with GObject.Object.unref().

Return type:

[UDisks.Block]

Gets all the UDisks.Block instances with the given label, if any.

get_block_for_mdraid(raid)
Parameters:

raid (UDisks.MDRaid) – A UDisks.MDRaid.

Returns:

A UDisks.Block or None if no RAID device is running.

Return type:

UDisks.Block

Gets the RAID device (e.g. /dev/md0) for raid.

In the case of a split-brain syndrome, it is undefined which RAID device is returned. For example this can happen if /dev/sda and /dev/sdb are components of a two-disk RAID-1 and /dev/md0 and /dev/md1 are two degraded arrays, each one using exactly one of the two devices. Use UDisks.Client.get_all_blocks_for_mdraid() to get all RAID devices.

New in version 2.1.

get_block_for_uuid(uuid)
Parameters:

uuid (str) – The uuid.

Returns:

A list of UDisks.Block instances. The returned list should be freed with g_list_free() after each element has been freed with GObject.Object.unref().

Return type:

[UDisks.Block]

Gets all the UDisks.Block instances with the given uuid, if any.

get_cleartext_block(block)
Parameters:

block (UDisks.Block) – A UDisks.Block.

Returns:

A UDisks.Block or None. Free with GObject.Object.unref() when done with it.

Return type:

UDisks.Block

If block is an unlocked encrypted device, gets the cleartext device.

get_drive_for_block(block)
Parameters:

block (UDisks.Block) – A UDisks.Block.

Returns:

A UDisks.Drive or None if there is no UDisks.Drive for block - free the returned object with GObject.Object.unref().

Return type:

UDisks.Drive

Gets the UDisks.Drive that block belongs to, if any.

get_drive_info(drive)
Parameters:

drive (UDisks.Drive) – A UDisks.Drive.

Returns:

out_name:

Return location for name or None.

out_description:

Return location for description or None.

out_drive_icon:

Return location for icon representing the drive or None.

out_media_description:

Return location for description of the media or None.

out_media_icon:

Return location for icon representing the media or None.

Return type:

(out_name: str, out_description: str, out_drive_icon: Gio.Icon, out_media_description: str, out_media_icon: Gio.Icon)

Gets information about a UDisks.Drive object that is suitable to present in an user interface. The returned strings are localized.

Deprecated since version 2.1: Use UDisks.Client.get_object_info() instead.

get_drive_siblings(drive)
Parameters:

drive (UDisks.Drive) – A UDisks.Drive.

Returns:

A list of UDisks.Drive instances. The returned list should be freed with g_list_free() after each element has been freed with GObject.Object.unref().

Return type:

[UDisks.Drive]

Gets all siblings for drive.

New in version 2.1.

get_id_for_display(usage, type, version, long_string)
Parameters:
  • usage (str) – Usage id e.g. “filesystem” or “crypto”.

  • type (str) – Type e.g. “ext4” or “crypto_LUKS”

  • version (str) – Version.

  • long_string (bool) – Whether to produce a long string.

Returns:

A string that should be freed with GLib.free().

Return type:

str

Gets a human readable localized string for usage, type and version.

get_job_description(job)
Parameters:

job (UDisks.Job) – A UDisks.Job.

Returns:

A string that should be freed with GLib.free().

Return type:

str

Gets a human-readable and localized text string describing the operation of job.

For known job types, see the documentation for the

Job:Operation D-Bus property.

get_jobs_for_object(object)
Parameters:

object (UDisks.Object) – A UDisks.Object.

Returns:

A list of UDisks.Job instances. The returned list should be freed with g_list_free() after each element has been freed with GObject.Object.unref().

Return type:

[UDisks.Job]

Gets all the UDisks.Job instances that reference object, if any.

get_loop_for_block(block)
Parameters:

block (UDisks.Block) – A UDisks.Block.

Returns:

A UDisks.Loop or None. Free with GObject.Object.unref().

Return type:

UDisks.Loop

Gets the corresponding loop interface for block.

This only works if block itself is a loop device or a partition of a loop device.

get_manager()
Returns:

A UDisks.Manager or None if the udisksd daemon is not currently running. Do not free, the instance is owned by self.

Return type:

UDisks.Manager

Gets the UDisks.Manager interface on the well-known /org/freedesktop/UDisks2/Manager object.

get_mdraid_for_block(block)
Parameters:

block (UDisks.Block) – A UDisks.Block.

Returns:

A UDisks.MDRaid or None if there is no UDisks.MDRaid for block or block is not a MD-RAID block device. Free the returned object with GObject.Object.unref().

Return type:

UDisks.MDRaid

Gets the UDisks.MDRaid that block is the block device for, if any.

New in version 2.1.

get_media_compat_for_display(media_compat)
Parameters:

media_compat (str) – An array of media types.

Returns:

A string that should be freed with GLib.free() or None if unknown.

Return type:

str

Gets a human-readable string of the media described by media_compat. The returned information is localized.

get_members_for_mdraid(raid)
Parameters:

raid (UDisks.MDRaid) – A UDisks.MDRaid.

Returns:

A list of UDisks.Block instances. The returned list should be freed with g_list_free() after each element has been freed with GObject.Object.unref().

Return type:

[UDisks.Block]

Gets the physical block devices that are part of raid.

New in version 2.1.

get_object(object_path)
Parameters:

object_path (str) – Object path.

Returns:

A UDisks.Object corresponding to object_path or None if not found. The returned object must be freed with GObject.Object.unref().

Return type:

UDisks.Object

Convenience function for looking up an UDisks.Object for object_path.

get_object_info(object)
Parameters:

object (UDisks.Object) – A UDisks.Object.

Returns:

A UDisks.ObjectInfo instance that should be freed with GObject.Object.unref().

Return type:

UDisks.ObjectInfo

Gets information about a UDisks.Object instance that is suitable to present in an user interface. Information is returned in the UDisks.ObjectInfo object and is localized.

New in version 2.1.

get_object_manager()
Returns:

A Gio.DBusObjectManager. Do not free, the instance is owned by self.

Return type:

Gio.DBusObjectManager

Gets the Gio.DBusObjectManager used by self.

get_partition_info(partition)
Parameters:

partition (UDisks.Partition) –

UDisks.Partition.

Returns:

A string that should be freed with GLib.free().

Return type:

str

Gets information about partition that is suitable to present in an user interface in a single line of text.

The returned string is localized and includes things like the partition type, flags (if any) and name (if any).

get_partition_table(partition)
Parameters:

partition (UDisks.Partition) – A UDisks.Partition.

Returns:

A UDisks.PartitionTable. Free with GObject.Object.unref().

Return type:

UDisks.PartitionTable

Gets the UDisks.PartitionTable corresponding to partition.

get_partition_table_subtype_for_display(partition_table_type, partition_table_subtype)
Parameters:
  • partition_table_type (str) – A partition table type e.g. ‘dos’ or ‘gpt’.

  • partition_table_subtype (str) – A partition table type e.g. ‘dos’ or ‘gpt’.

Returns:

A description of partition_table_type and partition_table_subtype or None.

Return type:

str

Gets a human readable localized string for partition_table_type and partition_table_subtype.

get_partition_table_subtypes(partition_table_type)
Parameters:

partition_table_type (str) – A partition table type e.g. ‘dos’ or ‘gpt’.

Returns:

A None-terminated array of strings. Only the container should be freed with GLib.free().

Return type:

[str]

Gets all known subtypes for partition_table_type.

get_partition_table_type_for_display(partition_table_type)
Parameters:

partition_table_type (str) – A partition table type e.g. ‘dos’ or ‘gpt’.

Returns:

A description of partition_table_type or None.

Return type:

str

Gets a human readable localized string for partition_table_type.

get_partition_type_and_subtype_for_display(partition_table_type, partition_table_subtype, partition_type)
Parameters:
  • partition_table_type (str) – A partitioning type e.g. ‘dos’ or ‘gpt’.

  • partition_table_subtype (str) – A partitioning subtype or None.

  • partition_type (str) – A partition type.

Returns:

A description of partition_type or None if unknown.

Return type:

str

Like UDisks.Client.get_partition_type_for_display() but also takes the partition table subtype into account, if available. This is useful in scenarios where different subtypes is using the same partition type.

New in version 2.1.1.

get_partition_type_for_display(partition_table_type, partition_type)
Parameters:
  • partition_table_type (str) – A partitioning type e.g. ‘dos’ or ‘gpt’.

  • partition_type (str) – A partition type.

Returns:

A description of partition_type or None if unknown.

Return type:

str

Gets a human readable localized string for partiton_table_type and partition_type.

get_partition_type_infos(partition_table_type, partition_table_subtype)
Parameters:
  • partition_table_type (str) – A partition table type e.g. ‘dos’ or ‘gpt’.

  • partition_table_subtype (str or None) – A partition table subtype or None to get all known types.

Returns:

A list of UDisks.PartitionTypeInfo instances. The returned list should be freed with g_list_free() after freeing each element with UDisks.PartitionTypeInfo.free().

Return type:

[UDisks.PartitionTypeInfo]

Gets information about all known partition types for partition_table_type and partition_table_subtype.

get_partitions(table)
Parameters:

table (UDisks.PartitionTable) – A UDisks.PartitionTable.

Returns:

A list of UDisks.Partition instances. The returned list should be freed with g_list_free() after each element has been freed with GObject.Object.unref().

Return type:

[UDisks.Partition]

Gets all partitions of table.

get_size_for_display(size, use_pow2, long_string)
Parameters:
  • size (int) – Size in bytes

  • use_pow2 (bool) – Whether power-of-two units should be used instead of power-of-ten units.

  • long_string (bool) – Whether to produce a long string.

Returns:

A string that should be freed with GLib.free().

Return type:

str

Utility function to get a human-readable string that represents size.

peek_object(object_path)
Parameters:

object_path (str) – Object path.

Returns:

A UDisks.Object corresponding to object_path or None if not found.

Return type:

UDisks.Object

Like UDisks.Client.get_object() but doesn’t increase the reference count on the returned UDisks.Object.

The returned object is only valid until removed so it is only safe to use this function on the thread where self was constructed. Use UDisks.Client.get_object() if on another thread.

queue_changed()

Queues up a UDisks.Client ::changed signal and rate-limit it. See the documentation for the UDisks.Client ::changed property for more information.

New in version 2.1.

settle()

Blocks until all pending D-Bus messages have been delivered. Also emits the (rate-limited) UDisks.Client ::changed signal if changes are currently pending.

This is useful in two situations: 1. when using synchronous method calls since e.g. D-Bus signals received while waiting for the reply are queued up and dispatched after the synchronous call ends; and

when using asynchronous calls where the return value references a newly created object (such as the Manager.LoopSetup() method).

Signal Details

UDisks.Client.signals.changed(client)
Signal Name:

changed

Flags:

RUN_LAST

Parameters:

client (UDisks.Client) – The object which received the signal

This signal is emitted either when an object or interface is added or removed a when property has changed. Additionally, multiple received signals are coalesced into a single signal that is rate-limited to fire at most every 100ms.

Note that calling UDisks.Client.settle() will cause this signal to fire if any changes are outstanding.

For greater detail, connect to the Gio.DBusObjectManager ::object-added, Gio.DBusObjectManager ::object-removed, Gio.DBusObjectManager ::interface-added, Gio.DBusObjectManager ::interface-removed, Gio.DBusObjectManagerClient ::interface-proxy-properties-changed and signals on the UDisks.Client :object-manager object.

Property Details

UDisks.Client.props.bus_connection
Name:

bus-connection

Type:

Gio.DBusConnection

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The Gio.DBusConnection used to create the UDisks.Client :object-manager, or None if one wasn’t specified during construction of the UDisks.Client (in which case a system bus connection is used).

New in version 2.9.0.

UDisks.Client.props.manager
Name:

manager

Type:

UDisks.Manager

Default Value:

None

Flags:

READABLE

The UDisks.Manager interface on the well-known /org/freedesktop/UDisks2/Manager object

UDisks.Client.props.object_manager
Name:

object-manager

Type:

Gio.DBusObjectManager

Default Value:

None

Flags:

READABLE

The Gio.DBusObjectManager used by the UDisks.Client instance.