From b08af9e8538bb11f1535d8794347ae9ef92e2f84 Mon Sep 17 00:00:00 2001 From: mbordash2 <43893544+mbordash2@users.noreply.github.com> Date: Fri, 6 Sep 2024 08:21:29 -0700 Subject: [PATCH] delete files in `.terraform` rather than sending them to trash (#2547) --- poetry.lock | 18 +----------------- pyproject.toml | 1 - runway/module/terraform.py | 7 +++++-- 3 files changed, 6 insertions(+), 20 deletions(-) diff --git a/poetry.lock b/poetry.lock index 9b2dffca5..d3cb3ec41 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2896,22 +2896,6 @@ files = [ attrs = "*" pbr = "*" -[[package]] -name = "send2trash" -version = "1.8.3" -description = "Send file to trash natively under Mac OS X, Windows and Linux" -optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,>=2.7" -files = [ - {file = "Send2Trash-1.8.3-py3-none-any.whl", hash = "sha256:0c31227e0bd08961c7665474a3d1ef7193929fedda4233843689baa056be46c9"}, - {file = "Send2Trash-1.8.3.tar.gz", hash = "sha256:b18e7a3966d99871aefeb00cfbcfdced55ce4871194810fc71f4aa484b953abf"}, -] - -[package.extras] -nativelib = ["pyobjc-framework-Cocoa", "pywin32"] -objc = ["pyobjc-framework-Cocoa"] -win32 = ["pywin32"] - [[package]] name = "setuptools" version = "71.0.2" @@ -3508,4 +3492,4 @@ test = ["big-O", "importlib-resources", "jaraco.functools", "jaraco.itertools", [metadata] lock-version = "2.0" python-versions = ">=3.9, <3.13" -content-hash = "6001058ff738862292efbb820abc8091ff782e728088bd53749753e3d868c515" +content-hash = "6e3331fedf68a21badd5dda6a784bc9a85654fd925a43afb59ace049c4d07036" diff --git a/pyproject.toml b/pyproject.toml index b61e94a5d..11dbf0374 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -52,7 +52,6 @@ pyhcl = "^0.4" # does not support HCL2, possibly move to extras_require in the python-hcl2 = ">=3.0.0" pyyaml = ">5.4" requests = "*" -send2trash = "*" tomli = ">=1.2.2" troposphere = ">=2.4, <5" typing_extensions = "*" # only really needed for < 3.8 but can still be used in >= 3.8 diff --git a/runway/module/terraform.py b/runway/module/terraform.py index 1def347fe..3b9c65f3a 100644 --- a/runway/module/terraform.py +++ b/runway/module/terraform.py @@ -5,13 +5,13 @@ import json import logging import re +import shutil import subprocess import sys from pathlib import Path from typing import TYPE_CHECKING, Any, cast import hcl -from send2trash import send2trash from typing_extensions import Literal from .._logging import PrefixAdaptor @@ -414,7 +414,10 @@ def cleanup_dot_terraform(self) -> None: self.logger.debug("directory retained: %s", child) continue self.logger.debug("removing: %s", child) - send2trash(str(child)) # does not support Path objects + if child.is_dir(): + shutil.rmtree(child, ignore_errors=True) + else: + child.unlink(missing_ok=True) def deploy(self) -> None: """Run Terraform apply."""