-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathtest.py
More file actions
45 lines (41 loc) · 1.41 KB
/
test.py
File metadata and controls
45 lines (41 loc) · 1.41 KB
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
import code
import sys
import ast
def parse_config(filename):
configs = []
with open(filename, "r") as file:
lines = file.readlines()
config = {}
for line in lines:
line = line.strip()
if not line: # Empty line
if config:
configs.append(config)
config = {}
continue
if line.startswith("#"): # Comment
continue
elif line.startswith("-----"): # Configuration separator
continue
elif line.startswith("Configuration"):
continue
else: # Configuration parameter with its value
parts = line.split()
keyval = parts[2]
keyval_parts = keyval.split("=")
key = keyval_parts[0]
val = keyval_parts[1]
config[key] = val
return configs
def main():
configs = parse_config("output.txt")
# Run code for all configs
for config in configs:
print("Running code with config {}".format(config))
try:
code.important_function(int(config["pressure"]), int(config["volume"]), int(config["velocity"]), ast.literal_eval(config["low_fuel"]))
print("Everything looks good!")
except Exception as err:
print("Something bad happened: ", err)
if __name__ == "__main__":
main()