Mount
- class Mount(*args, **kwargs)
The GMount
interface represents user-visible mounts. Note, when
porting from GnomeVFS, GMount
is the moral
equivalent of GnomeVFSVolume
.
GMount
is a ‘mounted’ filesystem that you can access. Mounted is in
quotes because it’s not the same as a UNIX mount, it might be a GVFS
mount, but you can still access the files on it if you use GIO. Might or
might not be related to a volume object.
Unmounting a GMount
instance is an asynchronous operation. For
more information about asynchronous operations, see AsyncResult
and Task
. To unmount a GMount
instance, first call
unmount_with_operation
with (at least) the GMount
instance and a AsyncReadyCallback
. The callback will be fired
when the operation has resolved (either with success or failure), and a
AsyncResult
structure will be passed to the callback. That
callback should then call unmount_with_operation_finish
with the GMount
and the AsyncResult
data to see if the
operation was completed successfully. If an error
is present when
unmount_with_operation_finish
is called, then it will be
filled with any error information.
Methods
- class Mount
-
- eject(flags: MountUnmountFlags, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None
Ejects a mount. This is an asynchronous operation, and is finished by calling
eject_finish()
with themount
andAsyncResult
data returned in thecallback
.Deprecated since version 2.22: Use
eject_with_operation()
instead.- Parameters:
flags – flags affecting the unmount if required for eject
cancellable – optional
Cancellable
object,None
to ignore.callback – a
AsyncReadyCallback
, orNone
.user_data – user data passed to
callback
.
- eject_finish(result: AsyncResult) bool
Finishes ejecting a mount. If any errors occurred during the operation,
error
will be set to contain the errors andFalse
will be returned.Deprecated since version 2.22: Use
eject_with_operation_finish()
instead.- Parameters:
result – a
AsyncResult
.
- eject_with_operation(flags: MountUnmountFlags, mount_operation: MountOperation | None = None, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None
Ejects a mount. This is an asynchronous operation, and is finished by calling
eject_with_operation_finish()
with themount
andAsyncResult
data returned in thecallback
.Added in version 2.22.
- Parameters:
flags – flags affecting the unmount if required for eject
mount_operation – a
MountOperation
orNone
to avoid user interaction.cancellable – optional
Cancellable
object,None
to ignore.callback – a
AsyncReadyCallback
, orNone
.user_data – user data passed to
callback
.
- eject_with_operation_finish(result: AsyncResult) bool
Finishes ejecting a mount. If any errors occurred during the operation,
error
will be set to contain the errors andFalse
will be returned.Added in version 2.22.
- Parameters:
result – a
AsyncResult
.
- get_default_location() File
Gets the default location of
mount
. The default location of the givenmount
is a path that reflects the main entry point for the user (e.g. the home directory, or the root of the volume).
- get_drive() Drive | None
Gets the drive for the
mount
.This is a convenience method for getting the
Volume
and then using that object to get theDrive
.
- get_uuid() str | None
Gets the UUID for the
mount
. The reference is typically based on the file system UUID for the mount in question and should be considered an opaque string. ReturnsNone
if there is no UUID available.
- guess_content_type(force_rescan: bool, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None
Tries to guess the type of content stored on
mount
. Returns one or more textual identifiers of well-known content types (typically prefixed with “x-content/”), e.g. x-content/image-dcf for camera memory cards. See the shared-mime-info specification for more on x-content types.This is an asynchronous operation (see
guess_content_type_sync()
for the synchronous version), and is finished by callingguess_content_type_finish()
with themount
andAsyncResult
data returned in thecallback
.Added in version 2.18.
- Parameters:
force_rescan – Whether to force a rescan of the content. Otherwise a cached result will be used if available
cancellable – optional
Cancellable
object,None
to ignorecallback – a
AsyncReadyCallback
user_data – user data passed to
callback
- guess_content_type_finish(result: AsyncResult) list[str]
Finishes guessing content types of
mount
. If any errors occurred during the operation,error
will be set to contain the errors andFalse
will be returned. In particular, you may get anNOT_SUPPORTED
if the mount does not support content guessing.Added in version 2.18.
- Parameters:
result – a
AsyncResult
- guess_content_type_sync(force_rescan: bool, cancellable: Cancellable | None = None) list[str]
Tries to guess the type of content stored on
mount
. Returns one or more textual identifiers of well-known content types (typically prefixed with “x-content/”), e.g. x-content/image-dcf for camera memory cards. See the shared-mime-info specification for more on x-content types.This is a synchronous operation and as such may block doing IO; see
guess_content_type()
for the asynchronous version.Added in version 2.18.
- Parameters:
force_rescan – Whether to force a rescan of the content. Otherwise a cached result will be used if available
cancellable – optional
Cancellable
object,None
to ignore
- is_shadowed() bool
Determines if
mount
is shadowed. Applications or libraries should avoid displayingmount
in the user interface if it is shadowed.A mount is said to be shadowed if there exists one or more user visible objects (currently
Mount
objects) with a root that is inside the root ofmount
.One application of shadow mounts is when exposing a single file system that is used to address several logical volumes. In this situation, a
VolumeMonitor
implementation would create twoVolume
objects (for example, one for the camera functionality of the device and one for a SD card reader on the device) with activation URIsgphoto2://[usb:001,002]/store1/
andgphoto2://[usb:001,002]/store2/
. When the underlying mount (with rootgphoto2://[usb:001,002]/
) is mounted, saidVolumeMonitor
implementation would create twoMount
objects (each with their root matching the corresponding volume activation root) that would shadow the original mount.The proxy monitor in GVfs 2.26 and later, automatically creates and manage shadow mounts (and shadows the underlying mount) if the activation root on a
Volume
is set.Added in version 2.20.
- remount(flags: MountMountFlags, mount_operation: MountOperation | None = None, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None
Remounts a mount. This is an asynchronous operation, and is finished by calling
remount_finish()
with themount
andAsyncResult
data returned in thecallback
.Remounting is useful when some setting affecting the operation of the volume has been changed, as these may need a remount to take affect. While this is semantically equivalent with unmounting and then remounting not all backends might need to actually be unmounted.
- Parameters:
flags – flags affecting the operation
mount_operation – a
MountOperation
orNone
to avoid user interaction.cancellable – optional
Cancellable
object,None
to ignore.callback – a
AsyncReadyCallback
, orNone
.user_data – user data passed to
callback
.
- remount_finish(result: AsyncResult) bool
Finishes remounting a mount. If any errors occurred during the operation,
error
will be set to contain the errors andFalse
will be returned.- Parameters:
result – a
AsyncResult
.
- shadow() None
Increments the shadow count on
mount
. Usually used byVolumeMonitor
implementations when creating a shadow mount formount
, seeis_shadowed()
for more information. The caller will need to emit theMount
::changed signal onmount
manually.Added in version 2.20.
- unmount(flags: MountUnmountFlags, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None
Unmounts a mount. This is an asynchronous operation, and is finished by calling
unmount_finish()
with themount
andAsyncResult
data returned in thecallback
.Deprecated since version 2.22: Use
unmount_with_operation()
instead.- Parameters:
flags – flags affecting the operation
cancellable – optional
Cancellable
object,None
to ignore.callback – a
AsyncReadyCallback
, orNone
.user_data – user data passed to
callback
.
- unmount_finish(result: AsyncResult) bool
Finishes unmounting a mount. If any errors occurred during the operation,
error
will be set to contain the errors andFalse
will be returned.Deprecated since version 2.22: Use
unmount_with_operation_finish()
instead.- Parameters:
result – a
AsyncResult
.
- unmount_with_operation(flags: MountUnmountFlags, mount_operation: MountOperation | None = None, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None
Unmounts a mount. This is an asynchronous operation, and is finished by calling
unmount_with_operation_finish()
with themount
andAsyncResult
data returned in thecallback
.Added in version 2.22.
- Parameters:
flags – flags affecting the operation
mount_operation – a
MountOperation
orNone
to avoid user interaction.cancellable – optional
Cancellable
object,None
to ignore.callback – a
AsyncReadyCallback
, orNone
.user_data – user data passed to
callback
.
- unmount_with_operation_finish(result: AsyncResult) bool
Finishes unmounting a mount. If any errors occurred during the operation,
error
will be set to contain the errors andFalse
will be returned.Added in version 2.22.
- Parameters:
result – a
AsyncResult
.
- unshadow() None
Decrements the shadow count on
mount
. Usually used byVolumeMonitor
implementations when destroying a shadow mount formount
, seeis_shadowed()
for more information. The caller will need to emit theMount
::changed signal onmount
manually.Added in version 2.20.
Signals
Virtual Methods
- class Mount
-
- do_eject(flags: MountUnmountFlags, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None
Ejects a mount. This is an asynchronous operation, and is finished by calling
eject_finish()
with themount
andAsyncResult
data returned in thecallback
.Deprecated since version 2.22: Use
eject_with_operation()
instead.- Parameters:
flags – flags affecting the unmount if required for eject
cancellable – optional
Cancellable
object,None
to ignore.callback – a
AsyncReadyCallback
, orNone
.user_data – user data passed to
callback
.
- do_eject_finish(result: AsyncResult) bool
Finishes ejecting a mount. If any errors occurred during the operation,
error
will be set to contain the errors andFalse
will be returned.Deprecated since version 2.22: Use
eject_with_operation_finish()
instead.- Parameters:
result – a
AsyncResult
.
- do_eject_with_operation(flags: MountUnmountFlags, mount_operation: MountOperation | None = None, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None
Ejects a mount. This is an asynchronous operation, and is finished by calling
eject_with_operation_finish()
with themount
andAsyncResult
data returned in thecallback
.Added in version 2.22.
- Parameters:
flags – flags affecting the unmount if required for eject
mount_operation – a
MountOperation
orNone
to avoid user interaction.cancellable – optional
Cancellable
object,None
to ignore.callback – a
AsyncReadyCallback
, orNone
.user_data – user data passed to
callback
.
- do_eject_with_operation_finish(result: AsyncResult) bool
Finishes ejecting a mount. If any errors occurred during the operation,
error
will be set to contain the errors andFalse
will be returned.Added in version 2.22.
- Parameters:
result – a
AsyncResult
.
- do_get_default_location() File
Gets the default location of
mount
. The default location of the givenmount
is a path that reflects the main entry point for the user (e.g. the home directory, or the root of the volume).
- do_get_drive() Drive | None
Gets the drive for the
mount
.This is a convenience method for getting the
Volume
and then using that object to get theDrive
.
- do_get_uuid() str | None
Gets the UUID for the
mount
. The reference is typically based on the file system UUID for the mount in question and should be considered an opaque string. ReturnsNone
if there is no UUID available.
- do_guess_content_type(force_rescan: bool, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None
Tries to guess the type of content stored on
mount
. Returns one or more textual identifiers of well-known content types (typically prefixed with “x-content/”), e.g. x-content/image-dcf for camera memory cards. See the shared-mime-info specification for more on x-content types.This is an asynchronous operation (see
guess_content_type_sync()
for the synchronous version), and is finished by callingguess_content_type_finish()
with themount
andAsyncResult
data returned in thecallback
.Added in version 2.18.
- Parameters:
force_rescan – Whether to force a rescan of the content. Otherwise a cached result will be used if available
cancellable – optional
Cancellable
object,None
to ignorecallback – a
AsyncReadyCallback
user_data – user data passed to
callback
- do_guess_content_type_finish(result: AsyncResult) list[str]
Finishes guessing content types of
mount
. If any errors occurred during the operation,error
will be set to contain the errors andFalse
will be returned. In particular, you may get anNOT_SUPPORTED
if the mount does not support content guessing.Added in version 2.18.
- Parameters:
result – a
AsyncResult
- do_guess_content_type_sync(force_rescan: bool, cancellable: Cancellable | None = None) list[str]
Tries to guess the type of content stored on
mount
. Returns one or more textual identifiers of well-known content types (typically prefixed with “x-content/”), e.g. x-content/image-dcf for camera memory cards. See the shared-mime-info specification for more on x-content types.This is a synchronous operation and as such may block doing IO; see
guess_content_type()
for the asynchronous version.Added in version 2.18.
- Parameters:
force_rescan – Whether to force a rescan of the content. Otherwise a cached result will be used if available
cancellable – optional
Cancellable
object,None
to ignore
- do_pre_unmount() None
The ::pre-unmount signal that is emitted when the
Mount
will soon be emitted. If the recipient is somehow holding the mount open by keeping an open file on it it should close the file.
- do_remount(flags: MountMountFlags, mount_operation: MountOperation | None = None, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None
Remounts a mount. This is an asynchronous operation, and is finished by calling
remount_finish()
with themount
andAsyncResult
data returned in thecallback
.Remounting is useful when some setting affecting the operation of the volume has been changed, as these may need a remount to take affect. While this is semantically equivalent with unmounting and then remounting not all backends might need to actually be unmounted.
- Parameters:
flags – flags affecting the operation
mount_operation – a
MountOperation
orNone
to avoid user interaction.cancellable – optional
Cancellable
object,None
to ignore.callback – a
AsyncReadyCallback
, orNone
.user_data – user data passed to
callback
.
- do_remount_finish(result: AsyncResult) bool
Finishes remounting a mount. If any errors occurred during the operation,
error
will be set to contain the errors andFalse
will be returned.- Parameters:
result – a
AsyncResult
.
- do_unmount(flags: MountUnmountFlags, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None
Unmounts a mount. This is an asynchronous operation, and is finished by calling
unmount_finish()
with themount
andAsyncResult
data returned in thecallback
.Deprecated since version 2.22: Use
unmount_with_operation()
instead.- Parameters:
flags – flags affecting the operation
cancellable – optional
Cancellable
object,None
to ignore.callback – a
AsyncReadyCallback
, orNone
.user_data – user data passed to
callback
.
- do_unmount_finish(result: AsyncResult) bool
Finishes unmounting a mount. If any errors occurred during the operation,
error
will be set to contain the errors andFalse
will be returned.Deprecated since version 2.22: Use
unmount_with_operation_finish()
instead.- Parameters:
result – a
AsyncResult
.
- do_unmount_with_operation(flags: MountUnmountFlags, mount_operation: MountOperation | None = None, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None
Unmounts a mount. This is an asynchronous operation, and is finished by calling
unmount_with_operation_finish()
with themount
andAsyncResult
data returned in thecallback
.Added in version 2.22.
- Parameters:
flags – flags affecting the operation
mount_operation – a
MountOperation
orNone
to avoid user interaction.cancellable – optional
Cancellable
object,None
to ignore.callback – a
AsyncReadyCallback
, orNone
.user_data – user data passed to
callback
.
- do_unmount_with_operation_finish(result: AsyncResult) bool
Finishes unmounting a mount. If any errors occurred during the operation,
error
will be set to contain the errors andFalse
will be returned.Added in version 2.22.
- Parameters:
result – a
AsyncResult
.