Skip to content

Commit

Permalink
Project tools
Browse files Browse the repository at this point in the history
  • Loading branch information
tristiisch committed Mar 25, 2024
1 parent a224e23 commit da96c0c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 9 deletions.
9 changes: 0 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ DOCKER_CONTEXT_PREPROD := cookie-pulsheberg

.PHONY: logs

# ifeq ($(OS),Windows_NT)
# else
# endif

all: start-f logs

start:
Expand Down Expand Up @@ -46,11 +42,6 @@ exec:
exec-pp:
@scripts/docker_service_exec.sh $(DOCKER_SERVICE_PREPROD) $(DOCKER_CONTEXT_PREPROD)

env-setup:
@python3 -m venv $(VENV_NAME)
@make env
@pip install -r requirements.txt

dev:
@docker compose -f $(DOCKER_COMPOSE_FILE_DEV) up -d --remove-orphans --build

Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ Feel free to fork the project while adhering to the license and acknowledging th

For seamless integration of your modifications, submitting pull requests to the original bot version is recommended.

## Setup local project

Install virtual python environnement on Unix
```
python -m venv .venv
source ./.venv/bin/activate
pip install -r requirements.txt
```

## License

[MIT](https://choosealicense.com/licenses/mit/)
Expand Down
23 changes: 23 additions & 0 deletions scripts/environnement.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import argparse
import subprocess
import sys
import os
import shutil

from pathlib import Path

def build_image():
subprocess.run("docker build -t local/pyramid .", shell=True)
Expand All @@ -11,11 +15,26 @@ def build_images_archs():
def remove_dangling_images():
subprocess.run("docker --log-level debug image prune -f", shell=True)

def clean_python_cache(directory):
count = 0
for root, dirs, files in os.walk(directory):
if '__pycache__' in dirs:
shutil.rmtree(os.path.join(root, '__pycache__'))
count += 1
if '.pytest_cache' in dirs:
shutil.rmtree(os.path.join(root, '.pytest_cache'))
count += 1
if '.coverage' in files:
os.remove(os.path.join(root, '.coverage'))
count += 1
print(f"{count} python cache was deleted.")

def parse_arguments():
parser = argparse.ArgumentParser(description="Manage application environnement")
parser.add_argument("--images-purge", action="store_true", help="Remove all Docker images without tags.")
parser.add_argument("--build", action="store_true", help="Build docker image.")
parser.add_argument("--build-archs", action="store_true", help="Build docker images for all supported arch.")
parser.add_argument("--clean", action="store_true", help="Delete python cache.")
return parser.parse_args()

def main():
Expand All @@ -28,6 +47,10 @@ def main():
build_images_archs()
elif args.images_purge:
remove_dangling_images()
elif args.clean:
current_file_directory = Path(__file__).resolve().parent
parent_directory = current_file_directory.parent
clean_python_cache(parent_directory)
else:
print("No action specified. Use --help for usage information.")
return
Expand Down

0 comments on commit da96c0c

Please sign in to comment.