-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlaunchfile_alacigri.py
executable file
·72 lines (61 loc) · 2.06 KB
/
launchfile_alacigri.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env python
# -*- coding:Utf-8 -*-
from __future__ import division
from pylab import *
""" Main library for the pair production """
import os
import sys
import re
from threading import Thread
from datetime import datetime
montableau = []
monpilote = []
nombretotal = 0
launchxmlaero = os.path.join(os.path.dirname(__file__), "launchxmlaero.py")
def LaunchAero(filename, threadnumber):
global montableau, monpilote
print "nombre de threads : ", threadnumber
fi = open(filename, 'r')
for line in fi:
if line.strip() != "":
montableau.append(line)
monpilote.append(0)
# L'execution consiste a chercher une valeur à 0 dans le tableau, a la faire passer à 1 et à executer l'equivalent de montableau.
# Ensuite, il suffit de mettre à 2 quand c'est fini
for i in range(0, threadnumber):
mythread = RunPlaneto(i)
mythread.start()
print "FINI?"
print nombretotal
class RunPlaneto(Thread):
def __init__(self, test):
Thread.__init__(self)
self.number = test
def search(self):
for i in range(0, len(monpilote)):
if monpilote[i] == 0:
return i
return -1
def run(self): # Run est appelle par start pour les threads
ok = True
while ok:
number = self.search()
if number == -1:
ok = False
else:
monpilote[number] = 1
print "le thread ", self.number, " prend le nombre ", number
launch = "nohup " + launchxmlaero + " " + montableau[number]
print launch
os.system(launch)
# os.system(os.path.join(os.path.dirname(__file__),"launchxmlaero.py") + " " + montableau[number])
global nombretotal
nombretotal += 1
def ftostr(truc):
return "%(str)f" % {"str": truc}
if __name__ == "__main__":
print "salut"
if len(sys.argv) != 3:
print "Usage: launchfile_alacigri.py file threadnb"
sys.exit()
LaunchAero(sys.argv[1], int(sys.argv[2]))