os¶
functions that an OS normally provides
The os module is a strict subset of the CPython os module. So,
code written in CircuitPython will work in CPython but not necessarily the
other way around.
-
os.uname() → Any¶ Returns a named tuple of operating specific and CircuitPython port specific information.
-
os.chdir(path: Any) → Any¶ Change current directory.
-
os.getcwd() → Any¶ Get the current directory.
-
os.listdir(dir: Any) → Any¶ With no argument, list the current directory. Otherwise list the given directory.
-
os.mkdir(path: Any) → Any¶ Create a new directory.
-
os.remove(path: Any) → Any¶ Remove a file.
-
os.rmdir(path: Any) → Any¶ Remove a directory.
-
os.rename(old_path: Any, new_path: Any) → Any¶ Rename a file.
-
os.stat(path: Any) → Any¶ Get the status of a file or directory.
Note
On builds without long integers, the number of seconds for contemporary dates will not fit in a small integer. So the time fields return 946684800, which is the number of seconds corresponding to 1999-12-31.
-
os.statvfs(path: Any) → Any¶ Get the status of a fileystem.
Returns a tuple with the filesystem information in the following order:
f_bsize– file system block sizef_frsize– fragment sizef_blocks– size of fs in f_frsize unitsf_bfree– number of free blocksf_bavail– number of free blocks for unpriviliged usersf_files– number of inodesf_ffree– number of free inodesf_favail– number of free inodes for unpriviliged usersf_flag– mount flagsf_namemax– maximum filename length
Parameters related to inodes:
f_files,f_ffree,f_availand thef_flagsparameter may return0as they can be unavailable in a port-specific implementation.
-
os.sync() → Any¶ Sync all filesystems.
-
os.urandom(size: Any) → Any¶ Returns a string of size random bytes based on a hardware True Random Number Generator. When not available, it will raise a NotImplementedError.