-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
46 lines (34 loc) · 1.03 KB
/
test.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 subprocess
def prep_command(comm, pd, mgs, mrc, pr):
comm = comm.strip()
comm = comm.split('"')
part_2 = comm[2].strip().split(' ')
comm.pop(2)
for i in part_2:
comm.append(i)
command_copy = comm.copy()
command_copy.append( str(pd))
command_copy.append( str(mgs))
command_copy.append( str(mrc))
command_copy.append( str(pr))
return command_copy
def black_box_function(pd, mgs, mrc, pr):
com = prep_command(command, pd, mgs, mrc, pr)
# print last 20 chars of the output
for i in com: print(i)
res = subprocess.run(com, stdout=subprocess.PIPE, shell=True).stdout.decode('utf-8')
res = res.split('\n')
res = res[-4]
score = 0
try:
score = float(res.split(' ')[-1][6:-2])
except:
score = 10
return score
command = open("command.txt", "r").read()
if __name__ == "__main__":
pd = 0.9708924196157915
mgs = 56.9239059211837
mrc = 0.03359814584366693
pr = 0.1290747299750546
print(black_box_function(pd, mgs, mrc, pr))