Skip to content

Commit 41551c6

Browse files
committed
Update clean command
1 parent 64c4e65 commit 41551c6

File tree

1 file changed

+13
-4
lines changed
  • Automation/Scripts/automation_scripts/commands

1 file changed

+13
-4
lines changed

Automation/Scripts/automation_scripts/commands/clean.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ def run(self, arguments: argparse.Namespace, simulate: bool, **kwargs) -> None:
3434
all_python_packages = project_configuration.list_automation_packages() + project_configuration.list_python_packages()
3535

3636
self.clean_artifacts(artifact_directory, simulate = simulate)
37+
self.clean_python_cache(os.path.join("Automation", "Setup"), simulate = simulate)
3738
for python_package in all_python_packages:
3839
self.clean_python_package(python_package, simulate = simulate)
40+
self.clean_pytest_cache(simulate = simulate)
3941

4042

4143
async def run_async(self, arguments: argparse.Namespace, simulate: bool, **kwargs) -> None:
@@ -56,7 +58,7 @@ def clean_python_package(self, python_package: PythonPackage, simulate: bool = F
5658
for directory in directories_to_remove:
5759
self._remove_directory(directory, simulate = simulate)
5860

59-
metadata_file_path = os.path.join(python_package.path_to_sources, "__metadata__.py")
61+
metadata_file_path = os.path.join(python_package.path_to_sources, python_package.name_for_file_system, "__metadata__.py")
6062
self._remove_file(metadata_file_path, simulate = simulate)
6163

6264
self.clean_python_cache(python_package.path_to_sources, simulate = simulate)
@@ -74,15 +76,22 @@ def clean_python_cache(self, source_directory: str, simulate: bool = False) -> N
7476
self._remove_directory(directory, simulate = simulate)
7577

7678

79+
def clean_pytest_cache(self, simulate: bool = False) -> None:
80+
directories_to_remove = [ ".pytest_cache" ]
81+
82+
for directory in directories_to_remove:
83+
self._remove_directory(directory, simulate = simulate)
84+
85+
7786
def _remove_directory(self, directory_to_remove: str, simulate: bool = False) -> None:
7887
if os.path.exists(directory_to_remove):
79-
logger.debug("Removing directory '%s'", directory_to_remove)
88+
logger.debug("Removing '%s'", directory_to_remove)
8089
if not simulate:
8190
shutil.rmtree(directory_to_remove)
8291

8392

8493
def _remove_file(self, file_to_remove: str, simulate: bool = False) -> None:
8594
if os.path.exists(file_to_remove):
86-
logger.debug("Removing file '%s'", file_to_remove)
95+
logger.debug("Removing '%s'", file_to_remove)
8796
if not simulate:
88-
shutil.rmtree(file_to_remove)
97+
os.remove(file_to_remove)

0 commit comments

Comments
 (0)