chmod -R /
(path: str, cwd: str='.')
| 110 | |
| 111 | @enforce_types |
| 112 | def chmod_file(path: str, cwd: str='.') -> None: |
| 113 | """chmod -R <permissions> <cwd>/<path>""" |
| 114 | |
| 115 | root = Path(cwd) / path |
| 116 | if not root.exists(): |
| 117 | raise Exception('Failed to chmod: {} does not exist (did the previous step fail?)'.format(path)) |
| 118 | |
| 119 | if not root.is_dir(): |
| 120 | # path is just a plain file |
| 121 | os.chmod(root, int(OUTPUT_PERMISSIONS, base=8)) |
| 122 | else: |
| 123 | for subpath in Path(path).glob('**/*'): |
| 124 | if subpath.is_dir(): |
| 125 | # directories need execute permissions to be able to list contents |
| 126 | os.chmod(subpath, int(DIR_OUTPUT_PERMISSIONS, base=8)) |
| 127 | else: |
| 128 | os.chmod(subpath, int(OUTPUT_PERMISSIONS, base=8)) |
| 129 | |
| 130 | |
| 131 | @enforce_types |
no outgoing calls
no test coverage detected