forked from jniediek/combinato
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_options.py
55 lines (41 loc) · 1.33 KB
/
setup_options.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
# JN 2016-05-12
"""
Setup options.py with the correct clustering binaries
"""
from __future__ import print_function
import os
import sys
import subprocess
OPT_PATH = os.path.join('combinato', 'options.py')
DEF_OPT_PATH = os.path.join('combinato', 'default_options.py')
def setup():
if os.path.isfile(OPT_PATH):
print(OPT_PATH + ' exists, not doing anything.')
return
platform = sys.platform
if "linux" in platform:
binary = 'cluster_linux64.exe'
elif "win32" in platform:
binary = 'cluster_64.exe'
elif "darwin" in platform:
binary = 'cluster_maci.exe'
binary = os.path.join(os.getcwd(),'spc', binary)
try:
subprocess.call(binary, stdout=subprocess.PIPE)
except OSError as error:
print('Could not execute SPC binary {}'.format(binary))
print(error)
return
print('Found and executed SPC binary {}'.format(binary))
# try to execute the binary
out_fname = OPT_PATH
in_fname = DEF_OPT_PATH
with open(in_fname, 'r') as in_fid:
lines = in_fid.readlines()
with open(out_fname, 'w') as out_fid:
for line in lines:
if line.startswith('CLUS_BINARY'):
line = 'CLUS_BINARY = \'{}\''.format(binary)
out_fid.write(line)
if __name__ == "__main__":
setup()