-
Notifications
You must be signed in to change notification settings - Fork 1
/
initialize_fireworks.py
63 lines (47 loc) · 2 KB
/
initialize_fireworks.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
56
57
58
59
60
61
62
63
#!/usr/bin/env python
import os
from jinja2 import Template
def main():
home = os.environ["HOME"]
logdir_launchpad = raw_input("Launchpad logging directory (e.g. %s): " % os.path.join(home, "fw", "logs", "launchpad"))
db_host = raw_input("Database host (e.g., x.mongolab.com): ")
db_name = raw_input("Database name (e.g., covertrack): ")
db_username = raw_input("Database username (e.g., fireworks): ")
db_password = raw_input("Database password (stored in plaintext, unfortunately): ")
db_port = raw_input("Database port: ")
logdir_qadapter = raw_input("Queue adapter logging directory (e.g. %s): " % os.path.join(home, "fw", "logs", "qadapter"))
covertrack_path = raw_input("covertrack path (e.g., %s): " % os.path.join(home, "covertrack"))
template_my_launchpad = os.path.join(covertrack_path, "fireworks", "my_launchpad.yaml")
my_launchpad = os.path.join(covertrack_path, "my_launchpad.yaml")
os.makedirs(logdir_launchpad)
os.makedirs(logdir_qadapter)
h = open(template_my_launchpad, "r")
t = Template(h.read())
h.close()
my_launchpad_text = t.render({
"LOGDIR_LAUNCHPAD": logdir_launchpad,
"DB_HOST": db_host,
"DB_NAME": db_name,
"DB_USERNAME": db_username,
"DB_PASSWORD": db_password,
"DB_PORT": db_port,
})
h = open(my_launchpad, "w")
h.write(my_launchpad_text)
h.close()
template_my_qadapter = os.path.join(covertrack_path, "fireworks", "my_qadapter.yaml")
my_qadapter = os.path.join(covertrack_path, "my_qadapter.yaml")
h = open(template_my_qadapter, "r")
t = Template(h.read())
h.close()
my_qadapter_text = t.render({
"LOGDIR_QADAPTER": logdir_qadapter,
"COVERTRACK_PATH": covertrack_path,
})
h = open(my_qadapter, "w")
h.write(my_qadapter_text)
h.close()
print "Created %s with the information provided." % my_launchpad
print "Created %s with the information provided." % my_qadapter
if __name__ == "__main__":
main()