diff --git a/Raspberry/Module_4G/processusEnvoi4G.py b/Raspberry/Module_4G/processusEnvoi4G.py index 717a6024be1a3b5484be0528aace8cf641e4e181..2dad4d64058e19ffcad78ea03c4dac4b9730b248 100755 --- a/Raspberry/Module_4G/processusEnvoi4G.py +++ b/Raspberry/Module_4G/processusEnvoi4G.py @@ -10,7 +10,7 @@ import os import os.path from datetime import datetime import psutil - +import shutil #def check_pid(pid): # # Verifie l'existence d'un pid @@ -34,6 +34,9 @@ else: # Si un processus s'est activée entre la 1ere boucle et la condition open(".lockprocess", "a").close() subprocess.Popen(["chmod", "777", ".lockprocess"]) +FOLDER = "data/" +TRAITEES = "traitees/" + IP_PC = "91.162.19.165" PORT = 20000 nomFichier = sys.argv[1] @@ -75,6 +78,8 @@ try: log.write(" => chunk "+str(totalEnvoyee)+"/"+str(taille)+"\n") server.close() + + shutil.move(FOLDER+chemin[1], TRAITEES+chemin[1]) except KeyboardInterrupt : print("============= LIBERATION =============") os.remove(".lockprocess") diff --git a/Raspberry/Module_4G/rapatriement.py b/Raspberry/Module_4G/rapatriement.py index a02373606726aa83735f07355ddad49d41085835..f05fe99435bbb0657678110b0b3b92035c2e4be5 100644 --- a/Raspberry/Module_4G/rapatriement.py +++ b/Raspberry/Module_4G/rapatriement.py @@ -8,6 +8,7 @@ import time import psutil import sys +""" def check_pid(pid): # Verifie l'existence d'un pid if psutil.pid_exists(pid): @@ -15,47 +16,48 @@ def check_pid(pid): if p.status() != psutil.STATUS_ZOMBIE: return True return False - +""" FOLDER = "data/" TRAITEES = "traitees/" DIR = os.listdir(FOLDER) -pid = -1 +#pid = -1 # Parcours les fichiers et les envois au serveur PC while True: try : - pid = subprocess.Popen(["wvdial"]) - print("============= WVDIAL LANCEE =============") - print("PID = ", pid.pid) + #pid = subprocess.Popen(["wvdial"]) + #print("============= WVDIAL LANCEE =============") + #print("PID = ", pid.pid) - time.sleep(10) + #time.sleep(10) - print("============= CORRECTION ROUTE =============") - subprocess.Popen(["route", "add", "default", "dev", "ppp0"]) + #print("============= CORRECTION ROUTE =============") + #subprocess.Popen(["route", "add", "default", "dev", "ppp0"]) for f in DIR : + time.sleep(5) if os.access(FOLDER+f, os.W_OK) and os.access(FOLDER+f, os.R_OK): print(FOLDER+f) process = subprocess.Popen(["python3", "processusEnvoi4G.py", FOLDER+f]) process.wait() print("Fin process") - shutil.move(FOLDER+f, TRAITEES+f) + #shutil.move(FOLDER+f, TRAITEES+f) print("Dossier data vide -- FIN") except KeyboardInterrupt: - print("============= WVDIAL ARRET =============") - subprocess.Popen(["kill", "-1", str(pid.pid)]) + #print("============= WVDIAL ARRET =============") + #subprocess.Popen(["kill", "-1", str(pid.pid)]) sys.exit(0) except Exception as ex: print(ex) - print("============= WVDIAL ARRET =============") - subprocess.Popen(["kill", "-1", str(pid.pid)]) + #print("============= WVDIAL ARRET =============") + #subprocess.Popen(["kill", "-1", str(pid.pid)]) - if check_pid(pid.pid): - print("============= WVDIAL ARRET =============") - subprocess.Popen(["kill", "-1", str(pid.pid)]) + #if check_pid(pid.pid): + #print("============= WVDIAL ARRET =============") + #subprocess.Popen(["kill", "-1", str(pid.pid)]) - time.sleep(21600) # Envoi toutes les 6 heures + time.sleep(3600) # Envoi toutes les 6 heures diff --git a/Raspberry/Module_4G/server.py b/Raspberry/Module_4G/server.py index 1e93d9b218cbd3bba4eb6908da46a0645d81ef09..8efc8214fa9472adf7806cf8b9eab051070c3c9e 100644 --- a/Raspberry/Module_4G/server.py +++ b/Raspberry/Module_4G/server.py @@ -36,7 +36,7 @@ while True: time.sleep(1) # Laisse le temps au port de se liberer break - print(" -> chunk") + #print(" -> chunk") except KeyboardInterrupt: if file is not None: