INNER CODE UNIT · Python
remove_readonly
GoogleCloudPlatform/terraform-python-testing-helper · tftest.py:306
def remove_readonly(func, path, excinfo):
_LOGGER.warning(f'Issue deleting file {path}, caused by {excinfo}')
os.chmod(path, stat.S_IWRITE)
func(path)
_LOGGER.debug('cleaning up %s %s', tfdir, filenames)
tf_path = Path(tfdir)
for filename in filenames:
(tf_path / filename).unlink(missing_ok=True)
if not deep:
return
terraform_dir = tf_path / '.terraform'
if terraform_dir.is_dir():
shutil.rmtree(terraform_dir, onerror=remove_readonly)
lock_file = tf_path / '.terraform.lock.hcl'