gio.Drive

gio.Drive — Virtual File System drive management.

Synopsis

class gio.Drive(gobject.GInterface):
    def can_eject()
def can_poll_for_media()
def eject(callback, flags=gio.MOUNT_UNMOUNT_NONE, cancellable=None, user_data=None)
def eject_finish(result)
def enumerate_identifiers()
def get_icon()
def get_identifier()
def get_name()
def get_volumes()
def has_media()
def has_volumes()
def is_media_check_automatic()
def is_media_removable()
def poll_for_media(callback, cancellable=None, user_data=None)
def poll_for_media_finish(result)

Ancestry

+-- gobject.GInterface
  +-- gio.Drive

Prerequisites

gio.Drive requires gobject.GObject

Description

gio.Drive - this represent a piece of hardware connected to the machine. Its generally only created for removable hardware or hardware with removable media.

gio.Drive is a container class for GVolume objects that stem from the same piece of media. As such, gio.Drive abstracts a drive with (or without) removable media and provides operations for querying whether media is available, determing whether media change is automatically detected and ejecting the media.

If the gio.Drive reports that media isn't automatically detected, one can poll for media; typically one should not do this periodically as a poll for media operation is potententially expensive and may spin up the drive creating noise.

For porting from GnomeVFS note that there is no equivalent of gio.Drive in that API.

Methods

gio.Drive.can_eject

    def can_eject()

Returns :

True if the drive can be ejected, False otherwise.

The can_eject() method checks if a drive can be ejected.

gio.Drive.can_poll_for_media

    def can_poll_for_media()

Returns :

True if the drive can be polled for media changes, False otherwise.

The can_poll_for_media() method checks if a drive can be polled for media changes.

gio.Drive.eject

    def eject(callback, flags=gio.MOUNT_UNMOUNT_NONE, cancellable=None, user_data=None)

callback :

A GAsyncReadyCallback to call when the request is satisfied.

flags :

flags affecting the unmount if required for eject.

cancellable :

Optional gio.Cancellable object, None to ignore.

user_data :

The data to pass to callback function.

The eject() method asynchronously ejects a drive.

When the operation is finished, callback will be called. You can then call gio.Drive.eject_finish() to obtain the result of the operation.

gio.Drive.eject_finish

    def eject_finish(result)

result :

a gio.AsyncResult.

Returns :

True if the drive has been ejected successfully, False otherwise.

The eject_finish() method finishes ejecting a drive.

gio.Drive.enumerate_identifiers

    def enumerate_identifiers()

Returns :

a list of strings containing kinds of identifiers.

The enumerate_identifiers() method gets the kinds of identifiers that drive has. Use gio.Drive.get_identifier() to obtain the identifiers themselves.

gio.Drive.get_icon

    def get_icon()

Returns :

gio.Icon for the drive.

The get_icon() method gets the icon for drive.

gio.Drive.get_identifier

    def get_identifier()

Returns :

A string containing the requested identfier, or None if the gio.Drive doesn't have this kind of identifier.

The get_identifier() method gets the identifier of the given kind for drive.

gio.Drive.get_name

    def get_name()

Returns :

A string containing drive's name.

The get_name() method gets the name of drive.

gio.Drive.get_volumes

    def get_volumes()

Returns :

A list containing any gio.Volume objects on the given drive.

The get_volumes() method get a list of mountable volumes for drive.

gio.Drive.has_media

    def has_media()

Returns :

True if drive has media, False otherwise.

The has_media() method checks if the drive has media. Note that the OS may not be polling the drive for media changes; see gio.Drive.is_media_check_automatic() for more details.

gio.Drive.has_volumes

    def has_volumes()

Returns :

True if drive contains volumes, False otherwise.

The has_volumes() method check if drive has any mountable volumes.

gio.Drive.is_media_check_automatic

    def is_media_check_automatic()

Returns :

True if drive is capabable of automatically detecting media changes, False otherwise.

The is_media_check_automatic() method checks if drive is capabable of automatically detecting media changes.

gio.Drive.is_media_removable

    def is_media_removable()

Returns :

True if drive supports removable media, False otherwise.

The is_media_removable() method checks if the drive supports removable media.

gio.Drive.poll_for_media

    def poll_for_media(callback, cancellable=None, user_data=None)

callback :

A GAsyncReadyCallback to call when the request is satisfied.

cancellable :

Optional gio.Cancellable object, None to ignore.

user_data :

The data to pass to callback function.

The poll_for_media() method asynchronously polls drive to see if media has been inserted or removed.

When the operation is finished, callback will be called. You can then call gio.Drive.poll_for_media_finish() to obtain the result of the operation.

gio.Drive.poll_for_media_finish

    def poll_for_media_finish(result)

result :

a gio.AsyncResult.

Returns :

True if the drive has been poll_for_mediaed successfully, False otherwise.

The poll_for_media_finish() method finishes an operation started with gio.Drive.poll_for_media() on a drive.