storage¶
Storage management
The storage provides storage management functionality such as mounting and
unmounting which is typically handled by the operating system hosting Python.
CircuitPython does not have an OS, so this module provides this functionality
directly.
-
storage.mount(filesystem: Any, mount_path: Any, *, readonly: bool = False) → Any¶ Mounts the given filesystem object at the given path.
This is the CircuitPython analog to the UNIX
mountcommand.- Parameters
readonly (bool) – True when the filesystem should be readonly to CircuitPython.
-
storage.umount(mount: Any) → Any¶ Unmounts the given filesystem object or if mount is a path, then unmount the filesystem mounted at that location.
This is the CircuitPython analog to the UNIX
umountcommand.
-
storage.remount(mount_path: Any, readonly: bool = False, *, disable_concurrent_write_protection: bool = False) → Any¶ Remounts the given path with new parameters.
- Parameters
readonly (bool) – True when the filesystem should be readonly to CircuitPython.
disable_concurrent_write_protection (bool) – When True, the check that makes sure the underlying filesystem data is written by one computer is disabled. Disabling the protection allows CircuitPython and a host to write to the same filesystem with the risk that the filesystem will be corrupted.
-
storage.getmount(mount_path: Any) → Any¶ Retrieves the mount object associated with the mount path
-
storage.erase_filesystem() → Any¶ Erase and re-create the
CIRCUITPYfilesystem.On boards that present USB-visible
CIRCUITPYdrive (e.g., SAMD21 and SAMD51), then callmicrocontroller.reset()to restart CircuitPython and have the host computer remount CIRCUITPY.This function can be called from the REPL when
CIRCUITPYhas become corrupted.Warning
All the data on
CIRCUITPYwill be lost, and CircuitPython will restart on certain boards.
-
class
storage.VfsFat(block_device: Any)¶ -
label:Any¶ The filesystem label, up to 11 case-insensitive bytes. Note that this property can only be set when the device is writable by the microcontroller.
-
mkfs(self)¶ Format the block device, deleting any data that may have been there
-
open(self, path: Any, mode: Any)¶ Like builtin
open()
-
ilistdir(self, path: Any)¶ Return an iterator whose values describe files and folders within
path
-
statvfs(self, path: Any)¶ Like
os.statvfs
-
mount(self, readonly: Any, mkfs: Any)¶ Don’t call this directly, call
storage.mount.
-
umount(self)¶ Don’t call this directly, call
storage.umount.
-