From 0dfc9356fe028448ea042431858b6238da34ff77 Mon Sep 17 00:00:00 2001 From: maxime Date: Tue, 31 Mar 2026 23:58:23 +0200 Subject: [PATCH] =?UTF-8?q?r=C3=A9organisation=20du=20tree?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + fastapi/main.sh | 12 +++++------- fastapi/run_api.sh | 2 +- flask/led.py | 22 ---------------------- main.sh => flask/main.sh | 13 ++++++++----- requirement.txt => flask/requirement.txt | 0 run_flask.sh => flask/run_flask.sh | 2 +- 7 files changed, 16 insertions(+), 36 deletions(-) delete mode 100644 flask/led.py rename main.sh => flask/main.sh (94%) rename requirement.txt => flask/requirement.txt (100%) rename run_flask.sh => flask/run_flask.sh (98%) diff --git a/.gitignore b/.gitignore index 9e9ee3b..dbdab7a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.pem .env +venv \ No newline at end of file diff --git a/fastapi/main.sh b/fastapi/main.sh index a02a9aa..88bb16c 100755 --- a/fastapi/main.sh +++ b/fastapi/main.sh @@ -58,7 +58,10 @@ sleep 1 #---------------------------- # 2. Installation de MariaDB x phpmyadmin #------------------------------ +read -p "Installer mariadb et phpMyAdmin ? (y/n)" db +if [ "$db" = 'y'];then bash DB/main.sh +fi #------------------------------- @@ -83,7 +86,6 @@ if ! apt install python3 python3-pip python3-venv -y; then fi PYTHON_VERSION=$(python3 --version 2>&1) echo " $PYTHON_VERSION installé" -echo " $PYTHON_VERSION installé" sleep 1 @@ -98,7 +100,6 @@ VENV_LIST=() for dir in "${SEARCH_DIRS[@]}"; do if [ -d "$dir" ]; then - # Un venv valide contient bin/activate et bin/python while IFS= read -r -d '' activate_path; do venv_dir=$(dirname "$(dirname "$activate_path")") if [ -f "$venv_dir/bin/python" ]; then @@ -154,27 +155,24 @@ if [[ "$CREATE_VENV" =~ ^[oO]$ ]]; then echo "Installation des dépendances depuis requirements.txt..." "$VENV_PATH/bin/pip" install -r ./requirements.txt echo " Dépendances installées" - echo " Dépendances installées" + else echo " Aucun requirements.txt trouvé, installation des dépendances ignorée" - echo " Aucun requirements.txt trouvé, installation des dépendances ignorée" + fi else - echo " Erreur lors de la création du venv à : $VENV_PATH" echo " Erreur lors de la création du venv à : $VENV_PATH" exit 1 fi else echo " Création ignorée" - echo " Création ignorée" fi # ---------------------------- # Fin # ---------------------------- print_step " Configuration terminée" -print_step " Configuration terminée" echo "" if [ -f "./.venv_path" ]; then echo "Venv configuré : $(cat ./.venv_path)" diff --git a/fastapi/run_api.sh b/fastapi/run_api.sh index 07e6728..205e34c 100755 --- a/fastapi/run_api.sh +++ b/fastapi/run_api.sh @@ -65,4 +65,4 @@ EOF sleep 1 touch /var/log/loustique.log chown ${SUDO_USER}:${SUDO_USER} /var/log/loustique.log -venv/bin/python main +venv/bin/python main.py diff --git a/flask/led.py b/flask/led.py deleted file mode 100644 index ef06c41..0000000 --- a/flask/led.py +++ /dev/null @@ -1,22 +0,0 @@ -from time import * -from gpiozero import * -from signal import pause -from log import log - -def led(utilisateur): - print('led allumé') - log.info(f'led allumé par {utilisateur}') - """ - print("One button to turn on or off") - led = LED(17) - btn = Button(20, bounce_time=None) - while True: - print('turn on') - led.on() - sleep(0.2) # to avoid bouncing - btn.wait_for_press() - print('turn off') - led.off() - sleep(0.2) # to avoid bouncing - btn.wait_for_press() - """ \ No newline at end of file diff --git a/main.sh b/flask/main.sh similarity index 94% rename from main.sh rename to flask/main.sh index a02a9aa..7d00783 100755 --- a/main.sh +++ b/flask/main.sh @@ -58,7 +58,11 @@ sleep 1 #---------------------------- # 2. Installation de MariaDB x phpmyadmin #------------------------------ + +read -p "Installer mariadb et phpMyAdmin ? (y/n)" db +if [ "$db" = 'y'];then bash DB/main.sh +fi #------------------------------- @@ -154,27 +158,26 @@ if [[ "$CREATE_VENV" =~ ^[oO]$ ]]; then echo "Installation des dépendances depuis requirements.txt..." "$VENV_PATH/bin/pip" install -r ./requirements.txt echo " Dépendances installées" - echo " Dépendances installées" + else echo " Aucun requirements.txt trouvé, installation des dépendances ignorée" - echo " Aucun requirements.txt trouvé, installation des dépendances ignorée" + fi else - echo " Erreur lors de la création du venv à : $VENV_PATH" echo " Erreur lors de la création du venv à : $VENV_PATH" exit 1 fi else echo " Création ignorée" - echo " Création ignorée" + fi # ---------------------------- # Fin # ---------------------------- print_step " Configuration terminée" -print_step " Configuration terminée" + echo "" if [ -f "./.venv_path" ]; then echo "Venv configuré : $(cat ./.venv_path)" diff --git a/requirement.txt b/flask/requirement.txt similarity index 100% rename from requirement.txt rename to flask/requirement.txt diff --git a/run_flask.sh b/flask/run_flask.sh similarity index 98% rename from run_flask.sh rename to flask/run_flask.sh index 24e56bf..5711f1d 100755 --- a/run_flask.sh +++ b/flask/run_flask.sh @@ -65,4 +65,4 @@ EOF sleep 1 touch /var/log/loustique.log chown ${SUDO_USER}:${SUDO_USER} /var/log/loustique.log -venv/bin/python ./flask/main.py +venv/bin/python main.py