Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Astreos_Arduino
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hicham Brahimi
Astreos_Arduino
Commits
a95a853f
Commit
a95a853f
authored
5 years ago
by
Hicham Brahimi
Browse files
Options
Downloads
Patches
Plain Diff
deplacement dans processusEnvoi
parent
3a12bbea
Branches
Branches containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Raspberry/Module_4G/processusEnvoi4G.py
+6
-1
6 additions, 1 deletion
Raspberry/Module_4G/processusEnvoi4G.py
Raspberry/Module_4G/rapatriement.py
+19
-17
19 additions, 17 deletions
Raspberry/Module_4G/rapatriement.py
Raspberry/Module_4G/server.py
+1
-1
1 addition, 1 deletion
Raspberry/Module_4G/server.py
with
26 additions
and
19 deletions
Raspberry/Module_4G/processusEnvoi4G.py
+
6
−
1
View file @
a95a853f
...
...
@@ -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
"
)
...
...
This diff is collapsed.
Click to expand it.
Raspberry/Module_4G/rapatriement.py
+
19
−
17
View file @
a95a853f
...
...
@@ -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
(
21
600
)
# Envoi toutes les 6 heures
time
.
sleep
(
3
600
)
# Envoi toutes les 6 heures
This diff is collapsed.
Click to expand it.
Raspberry/Module_4G/server.py
+
1
−
1
View file @
a95a853f
...
...
@@ -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
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment