mozfile is a convenience library for taking care of some common file-related tasks in automated testing, such as extracting files or recursively removing directories.
Takes in a tar or zip file and extracts it to dest
If dest is not specified, extracts to os.path.dirname(src)
Returns the list of top level files that were extracted
extract a .tar file
extract a zip file
Move a file or directory path.
This is a replacement for shutil.move that works better under windows, retrying operations on some known errors due to various things keeping a handle on file paths.
Removes the specified file, link, or directory tree.
This is a replacement for shutil.rmtree that works better under windows. It does the following things:
- check path access for the current user before trying to remove
- retry operations on some known errors due to various things keeping a handle on file paths - like explorer, virus scanners, etc. The known errors are errno.EACCES and errno.ENOTEMPTY, and it will retry up to 5 five times with a delay of (failed_attempts * 0.5) seconds between each attempt.
Note that no error will be raised if the given path does not exists.
Parameters: path – path to be removed