1 | import os |
---|
2 | import sys |
---|
3 | |
---|
4 | from default_param import * |
---|
5 | |
---|
6 | def main(): |
---|
7 | |
---|
8 | default_nb_config = 7 |
---|
9 | |
---|
10 | nb_config = 1; |
---|
11 | configs = [0]*default_nb_config |
---|
12 | |
---|
13 | configs_arg = [[], [], [], [], [], [], []] |
---|
14 | |
---|
15 | f=open("user_params.def", "r") |
---|
16 | for line in f: |
---|
17 | line = line.strip() |
---|
18 | if len(line) != 0: |
---|
19 | if not line.startswith("#"): |
---|
20 | nb_config = nb_config * (line.count(",")+1) |
---|
21 | line = line.replace(",", "") |
---|
22 | line = line.replace("=", "") |
---|
23 | if line.startswith("UsingServer2"): |
---|
24 | line = line.replace("UsingServer2", "") |
---|
25 | for word in line.split(): |
---|
26 | configs[0] += 1 |
---|
27 | configs_arg[0].append('UsingServer2 = '+word) |
---|
28 | elif line.startswith("RatioServer2"): |
---|
29 | line = line.replace("RatioServer2", "") |
---|
30 | for word in line.split(): |
---|
31 | configs[1] += 1 |
---|
32 | configs_arg[1].append('RatioServer2 = '+word) |
---|
33 | elif line.startswith("NumberPoolsServer2"): |
---|
34 | line = line.replace("NumberPoolsServer2", "") |
---|
35 | for word in line.split(): |
---|
36 | configs[2] += 1 |
---|
37 | configs_arg[2].append('NumberPoolsServer2 = '+word) |
---|
38 | elif line.startswith("NumberClients"): |
---|
39 | line = line.replace("NumberClients", "") |
---|
40 | for word in line.split(): |
---|
41 | configs[3] += 1 |
---|
42 | configs_arg[3].append('NumberClients = '+word) |
---|
43 | elif line.startswith("NumberServers"): |
---|
44 | line = line.replace("NumberServers", "") |
---|
45 | for word in line.split(): |
---|
46 | configs[4] += 1 |
---|
47 | configs_arg[4].append('NumberServers = '+word) |
---|
48 | elif line.startswith("Duration"): |
---|
49 | line = line.replace("Duration", "") |
---|
50 | for word in line.split(): |
---|
51 | configs[5] += 1 |
---|
52 | configs_arg[5].append('Duration = '+word) |
---|
53 | elif line.startswith("ATMdomain"): |
---|
54 | line = line.replace("ATMdomain", "") |
---|
55 | for word in line.split(): |
---|
56 | configs[6] += 1 |
---|
57 | configs_arg[6].append('ATMdomain = '+word) |
---|
58 | |
---|
59 | |
---|
60 | for x in range(default_nb_config): |
---|
61 | if configs[x]==0: |
---|
62 | configs[x] =1 |
---|
63 | |
---|
64 | config_id=0 |
---|
65 | for i0 in range(configs[0]): |
---|
66 | hasContent0 = len(configs_arg[0])>0 |
---|
67 | for i1 in range(configs[1]): |
---|
68 | hasContent1 = len(configs_arg[1])>0 |
---|
69 | for i2 in range(configs[2]): |
---|
70 | hasContent2 = len(configs_arg[2])>0 |
---|
71 | for i3 in range(configs[3]): |
---|
72 | hasContent3 = len(configs_arg[3])>0 |
---|
73 | for i4 in range(configs[4]): |
---|
74 | hasContent4 = len(configs_arg[4])>0 |
---|
75 | for i5 in range(configs[5]): |
---|
76 | hasContent5 = len(configs_arg[5])>0 |
---|
77 | for i6 in range(configs[6]): |
---|
78 | hasContent6 = len(configs_arg[6])>0 |
---|
79 | |
---|
80 | filename = "user_param.py."+repr(config_id) |
---|
81 | g = open(filename, "w") |
---|
82 | |
---|
83 | if hasContent0: g.write(configs_arg[0][i0]+'\n') |
---|
84 | if hasContent1: g.write(configs_arg[1][i1]+'\n') |
---|
85 | if hasContent2: g.write(configs_arg[2][i2]+'\n') |
---|
86 | if hasContent3: g.write(configs_arg[3][i3]+'\n') |
---|
87 | if hasContent4: g.write(configs_arg[4][i4]+'\n') |
---|
88 | if hasContent5: g.write(configs_arg[5][i5]+'\n') |
---|
89 | if hasContent6: g.write(configs_arg[6][i6]+'\n') |
---|
90 | |
---|
91 | config_id +=1 |
---|
92 | g.close |
---|
93 | |
---|
94 | |
---|
95 | print >>sys.stderr, nb_config |
---|
96 | |
---|
97 | |
---|
98 | if __name__== "__main__": |
---|
99 | main() |
---|