forked from ELSA-Project/ELSA-ABM
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·63 lines (46 loc) · 1.72 KB
/
setup.py
File metadata and controls
executable file
·63 lines (46 loc) · 1.72 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Setup script for the model. You can safely run this several times if you do not mess up too much
with libs/paths.py.
"""
import os
from os.path import join as jn
if __name__ == '__main__':
main_dir = os.path.split(os.path.abspath(__file__))[0]
print "Please type the path of the main directory for results. The path can be relative."
print "It will be created if it does not exist."
ans = raw_input("Leave blank (press enter) to use the default, which is ../results\n")
print "Writing libs/paths.py file..."
if ans=='':
ans = '../results'
result_dir = os.path.abspath(ans)
with open(os.path.join(main_dir, 'libs/paths.py')) as f:
lines = f.readlines()
new_lines = []
found = False
for l in lines:
if 'result_dir' in l and l[0]!='#':
new_lines.append('result_dir = "' + result_dir + '"')
found = True
else:
new_lines.append(l)
if not found:
new_lines.append('')
new_lines.append('result_dir = "' + result_dir + '"')
with open(jn(main_dir, 'libs', 'paths.py'), 'w') as f:
for line in new_lines:
f.write(line)
os.system('mkdir -p ' + result_dir)
os.system('mkdir -p ' + jn(result_dir, 'networks'))
os.system('mkdir -p ' + jn(result_dir, 'trajectories'))
os.system('mkdir -p ' + jn(result_dir, 'trajectories', 'M1'))
os.system('mkdir -p ' + jn(result_dir, 'trajectories', 'M3'))
os.system('cp ' + jn('abm_strategic', 'paras.py') + ' '+ jn('abm_strategic', 'my_paras.py'))
os.system('cp ' + jn('abm_strategic', 'paras_iter.py') + ' '+ jn('abm_strategic', 'my_paras_iter.py'))
print
print "Compiling C code and making wrapper..."
os.system("cd abm_tactical && ./compile.py")
print
print "Writing Documentation..."
os.system("./make_doc.py")