Commit a95a853f authored by Hicham Brahimi's avatar Hicham Brahimi

deplacement dans processusEnvoi

parent 3a12bbea
......@@ -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")
......
......@@ -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
......@@ -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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment