Mount#
- class Mount(*args, **kwargs)#
The GMount interface represents a user-visible mount, such as a mounted
file system.
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.
A GMount might be associated with a Volume (such as a USB flash
drive) which hosts it.
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.
Note, when porting from GnomeVFS, GMount is the
moral equivalent of GnomeVFSVolume.
Methods#
- class Mount
-
- async eject(self, flags: MountUnmountFlags) bool#
This is the awaitable version of
eject().Deprecated since version 2.22: Use
eject_with_operation()instead.- Parameters:
flags – flags affecting the unmount if required for eject
- eject(flags: MountUnmountFlags, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
Ejects a mount. This is an asynchronous operation, and is finished by calling
eject_finish()with themountandAsyncResultdata 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
Cancellableobject,Noneto 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,
errorwill be set to contain the errors andFalsewill be returned.Deprecated since version 2.22: Use
eject_with_operation_finish()instead.- Parameters:
result – a
AsyncResult.
- async eject_with_operation(self, flags: MountUnmountFlags, mount_operation: MountOperation | None = None) bool#
This is the awaitable version of
eject_with_operation().Added in version 2.22.
- Parameters:
flags – flags affecting the unmount if required for eject
mount_operation – a
MountOperationorNoneto avoid user interaction.
- eject_with_operation(flags: MountUnmountFlags, mount_operation: MountOperation | None = None, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
Ejects a mount. This is an asynchronous operation, and is finished by calling
eject_with_operation_finish()with themountandAsyncResultdata returned in thecallback.Added in version 2.22.
- Parameters:
flags – flags affecting the unmount if required for eject
mount_operation – a
MountOperationorNoneto avoid user interaction.cancellable – optional
Cancellableobject,Noneto 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,
errorwill be set to contain the errors andFalsewill 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 givenmountis 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
Volumeand 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. ReturnsNoneif there is no UUID available.
- async guess_content_type(self, force_rescan: bool) list[str]#
This is the awaitable version of
guess_content_type().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
- guess_content_type(force_rescan: bool, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) 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 themountandAsyncResultdata 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
Cancellableobject,Noneto ignorecallback – a
AsyncReadyCallbackuser_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,errorwill be set to contain the errors andFalsewill be returned. In particular, you may get anNOT_SUPPORTEDif 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
Cancellableobject,Noneto ignore
- is_shadowed() bool#
Determines if
mountis shadowed. Applications or libraries should avoid displayingmountin the user interface if it is shadowed.A mount is said to be shadowed if there exists one or more user visible objects (currently
Mountobjects) 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
VolumeMonitorimplementation would create twoVolumeobjects (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, saidVolumeMonitorimplementation would create twoMountobjects (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
Volumeis set.Added in version 2.20.
- async remount(self, flags: MountMountFlags, mount_operation: MountOperation | None = None) bool#
This is the awaitable version of
remount().- Parameters:
flags – flags affecting the operation
mount_operation – a
MountOperationorNoneto avoid user interaction.
- remount(flags: MountMountFlags, mount_operation: MountOperation | None = None, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
Remounts a mount. This is an asynchronous operation, and is finished by calling
remount_finish()with themountandAsyncResultdata 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
MountOperationorNoneto avoid user interaction.cancellable – optional
Cancellableobject,Noneto 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,
errorwill be set to contain the errors andFalsewill be returned.- Parameters:
result – a
AsyncResult.
- shadow() None#
Increments the shadow count on
mount. Usually used byVolumeMonitorimplementations when creating a shadow mount formount, seeis_shadowed()for more information. The caller will need to emit theMount::changed signal onmountmanually.Added in version 2.20.
- async unmount(self, flags: MountUnmountFlags) bool#
This is the awaitable version of
unmount().Deprecated since version 2.22: Use
unmount_with_operation()instead.- Parameters:
flags – flags affecting the operation
- unmount(flags: MountUnmountFlags, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
Unmounts a mount. This is an asynchronous operation, and is finished by calling
unmount_finish()with themountandAsyncResultdata returned in thecallback.Deprecated since version 2.22: Use
unmount_with_operation()instead.- Parameters:
flags – flags affecting the operation
cancellable – optional
Cancellableobject,Noneto 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,
errorwill be set to contain the errors andFalsewill be returned.Deprecated since version 2.22: Use
unmount_with_operation_finish()instead.- Parameters:
result – a
AsyncResult.
- async unmount_with_operation(self, flags: MountUnmountFlags, mount_operation: MountOperation | None = None) bool#
This is the awaitable version of
unmount_with_operation().Added in version 2.22.
- Parameters:
flags – flags affecting the operation
mount_operation – a
MountOperationorNoneto avoid user interaction.
- unmount_with_operation(flags: MountUnmountFlags, mount_operation: MountOperation | None = None, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
Unmounts a mount. This is an asynchronous operation, and is finished by calling
unmount_with_operation_finish()with themountandAsyncResultdata returned in thecallback.Added in version 2.22.
- Parameters:
flags – flags affecting the operation
mount_operation – a
MountOperationorNoneto avoid user interaction.cancellable – optional
Cancellableobject,Noneto 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,
errorwill be set to contain the errors andFalsewill be returned.Added in version 2.22.
- Parameters:
result – a
AsyncResult.
- unshadow() None#
Decrements the shadow count on
mount. Usually used byVolumeMonitorimplementations when destroying a shadow mount formount, seeis_shadowed()for more information. The caller will need to emit theMount::changed signal onmountmanually.Added in version 2.20.
Signals#
Virtual Methods#
- class Mount
-
- do_eject(flags: MountUnmountFlags, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
Ejects a mount. This is an asynchronous operation, and is finished by calling
eject_finish()with themountandAsyncResultdata 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
Cancellableobject,Noneto 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,
errorwill be set to contain the errors andFalsewill 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[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
Ejects a mount. This is an asynchronous operation, and is finished by calling
eject_with_operation_finish()with themountandAsyncResultdata returned in thecallback.Added in version 2.22.
- Parameters:
flags – flags affecting the unmount if required for eject
mount_operation – a
MountOperationorNoneto avoid user interaction.cancellable – optional
Cancellableobject,Noneto 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,
errorwill be set to contain the errors andFalsewill 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 givenmountis 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
Volumeand 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. ReturnsNoneif there is no UUID available.
- do_guess_content_type(force_rescan: bool, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) 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 themountandAsyncResultdata 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
Cancellableobject,Noneto ignorecallback – a
AsyncReadyCallbackuser_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,errorwill be set to contain the errors andFalsewill be returned. In particular, you may get anNOT_SUPPORTEDif 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
Cancellableobject,Noneto ignore
- do_remount(flags: MountMountFlags, mount_operation: MountOperation | None = None, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
Remounts a mount. This is an asynchronous operation, and is finished by calling
remount_finish()with themountandAsyncResultdata 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
MountOperationorNoneto avoid user interaction.cancellable – optional
Cancellableobject,Noneto 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,
errorwill be set to contain the errors andFalsewill be returned.- Parameters:
result – a
AsyncResult.
- do_unmount(flags: MountUnmountFlags, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
Unmounts a mount. This is an asynchronous operation, and is finished by calling
unmount_finish()with themountandAsyncResultdata returned in thecallback.Deprecated since version 2.22: Use
unmount_with_operation()instead.- Parameters:
flags – flags affecting the operation
cancellable – optional
Cancellableobject,Noneto 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,
errorwill be set to contain the errors andFalsewill 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[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
Unmounts a mount. This is an asynchronous operation, and is finished by calling
unmount_with_operation_finish()with themountandAsyncResultdata returned in thecallback.Added in version 2.22.
- Parameters:
flags – flags affecting the operation
mount_operation – a
MountOperationorNoneto avoid user interaction.cancellable – optional
Cancellableobject,Noneto 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,
errorwill be set to contain the errors andFalsewill be returned.Added in version 2.22.
- Parameters:
result – a
AsyncResult.