The standard library includes shutil.rmtree for this. By default,
shutil.rmtree(path) # errors if dir not empty
will give OSError: [Errno 66] Directory not empty:
.
You can delete the directory and its contents anyway by ignoring the error:
shutil.rmtree(role_fs_path, ignore_errors=True)
You can perform more sophisticated error handling by also passing onerrror=
.