-
Notifications
You must be signed in to change notification settings - Fork 0
/
runner.py
46 lines (38 loc) · 1.18 KB
/
runner.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import os
import time
import socket
from subprocess import Popen, PIPE
print("Compilation...")
os.system("mkdir obj")
os.system("mkdir bin")
os.system("make")
print("Démarrage du programme")
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8", 80))
print("Fichier à parser \n")
fileName = str(input())
print("Port serveur \n")
port = int(input())
verboseChoise = input("Mode verbeux ? (y/n) \n")
if verboseChoise == "y":
verbose = 1
else:
verbose = 0
f = open("Files/"+fileName, "r")
nbNode = 0
for x in f:
if x.startswith("p"):
nbNode = int(x.split(" ")[2])
break
print("Besoin de",nbNode , "clients")
file = '"' + fileName + '"'
print("[Runner] Démarrage du serveur sur " + str(port))
call = "./bin/serverMultiplex " + str(port) + " " + file + " " + str(verbose) + " &"
os.system(call)
time.sleep(1)
for x in range(0,nbNode) :
time.sleep(0.005)
tmpPort = port+x+1
print("[Runner] Démarrage du client" , x , "sur" , str(s.getsockname()[0]) + ":" + str(tmpPort) ,"au serveur")
call = "./bin/client "+ str(s.getsockname()[0]) + " " + str(port) + " " + str(s.getsockname()[0]) + " " + str(tmpPort) + " " + str(verbose) + " &"
os.system(call)