(d)
| 289 | # Removes a directory tree even if it was readonly, and doesn't throw exception |
| 290 | # on failure. |
| 291 | def remove_tree(d): |
| 292 | debug_print(f'remove_tree({d})') |
| 293 | if not os.path.exists(d): |
| 294 | return |
| 295 | try: |
| 296 | def remove_readonly_and_try_again(func, path, exc_info): |
| 297 | if not (os.stat(path).st_mode & stat.S_IWRITE): |
| 298 | os.chmod(path, stat.S_IWRITE) |
| 299 | func(path) |
| 300 | else: |
| 301 | raise exc_info[1] |
| 302 | shutil.rmtree(d, onerror=remove_readonly_and_try_again) |
| 303 | except Exception as e: |
| 304 | debug_print('remove_tree threw an exception, ignoring: ' + str(e)) |
| 305 | |
| 306 | |
| 307 | def win_set_environment_variable_direct(key, value, system=True): |
no test coverage detected