CARIA.2.2

Update for the final presentation
huge change with previous version
This commit is contained in:
ccunatbrule
2024-09-03 12:17:44 +02:00
parent ebcb596a4f
commit 2ddf2360e6
44 changed files with 7080 additions and 657 deletions

View File

@@ -25,69 +25,71 @@ def run_shell_fct(script):
script_name = os.path.basename(script)
# Se déplacer vers le répertoire du script et exécuter le script shell
return subprocess.Popen(["sudo", "./" + script_name], cwd=script_dir)
def main():
python_scripts = [
"apps/infrared_tracking_objects.py",
"apps/infrared_obstacle_avoidance.py",
"tests/servo_motor.py",
"tests/motor_speed_move.py",
"tests/rfid_read_write_module.py",
"tests/infrared_obstacle_module.py",
"tests/lidar_module.py"
]
python_fct = [
"WebControl/main.py"
]
shell_fct = [
]
# Liste pour stocker les PID des processus en cours d'exécution
running_processes = []
all_scripts = python_scripts + python_fct + shell_fct
display_menu(all_scripts)
choice = input("Votre choix (entrez le numéro du script) : ")
try:
choice_index = int(choice) - 1
if choice_index < 0 or choice_index >= len(all_scripts):
raise ValueError()
selected_script = all_scripts[choice_index]
# Vérifie si le script est Python ou Shell et l'exécute en conséquence
if selected_script in python_scripts:
process = run_python_script(selected_script)
elif selected_script in python_fct:
process = run_python_fct(selected_script)
elif selected_script in shell_fct:
process = run_shell_fct(selected_script)
# Ajouter le PID du processus à la liste
running_processes.append(process.pid)
except (ValueError, IndexError):
print("Choix invalide.")
sys.exit(1)
# Afficher les PID des processus en cours d'exécution
print("PID des processus en cours d'exécution :")
for pid in running_processes:
print(pid)
# Attente de l'arrêt du programme
input("Appuyez sur Entrée pour quitter...")
# Boucle pour terminer tous les processus en cours d'exécution
print("Termination des processus en cours...")
for pid in running_processes:
try:
os.kill(pid, signal.SIGTERM)
print(f"Processus {pid} terminé.")
except ProcessLookupError:
print(f"Le processus {pid} n'existe plus.")
if __name__ == "__main__":
main()
while True:
python_scripts = [
"apps/scenario_rfid.py",
"apps/rfid_read_write_module.py",
"apps/lidar_speed_move.py",
"apps/infrared_obstacle_avoidance.py",
"tests/servo_motor.py",
"tests/rfid_open_door.py",
"tests/motor_speed_move.py",
"tests/lidar_module.py",
"tests/infrared_obstacle_module.py"
]
python_fct = [
# "WebControl/main.py"
]
shell_fct = [
# "fixs/reboot.sh"
# "fixs/fix_rfid.sh",
# "fixs/fix_motion.sh",
]
# Liste pour stocker les PID des processus en cours d'exécution
running_processes = []
all_scripts = python_scripts + python_fct + shell_fct
display_menu(all_scripts)
choice = input("Votre choix (entrez le numéro du script) : ")
try:
choice_index = int(choice) - 1
if choice_index < 0 or choice_index >= len(all_scripts):
raise ValueError()
selected_script = all_scripts[choice_index]
# Vérifie si le script est Python ou Shell et l'exécute en conséquence
if selected_script in python_scripts:
process = run_python_script(selected_script)
elif selected_script in python_fct:
process = run_python_fct(selected_script)
elif selected_script in shell_fct:
process = run_shell_fct(selected_script)
# Ajouter le PID du processus à la liste
running_processes.append(process.pid)
except (ValueError, IndexError):
print("Choix invalide.")
sys.exit(1)
# Afficher les PID des processus en cours d'exécution
print("PID des processus en cours d'exécution :")
for pid in running_processes:
print(pid)
# Attente de l'arrêt du programme
input("Appuyez sur Entrée pour quitter...\n")
# Boucle pour terminer tous les processus en cours d'exécution
print("Fermeture des processus en cours...")
for pid in running_processes:
try:
os.kill(pid, signal.SIGTERM)
print(f"Processus {pid} terminé.\n")
except ProcessLookupError:
print(f"Le processus {pid} n'existe plus.")