-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
36 lines (32 loc) · 1.31 KB
/
setup.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
import os
import sys
rootDirectory = os.path.abspath(os.path.dirname(__file__))
def setupLogConfig():
logFileDir = os.path.join(rootDirectory, 'logs')
defaultLogFile = 'dga.log'
buf = "# DO NOT EDIT THIS FILE BY HAND. AUTO GENERATED FROM SETUP\n" + \
"LOG_DIRECTORY='"+logFileDir+"'\n"
logFilePath = os.path.join(logFileDir, defaultLogFile)
if not os.path.exists(os.path.dirname(logFilePath)):
os.makedirs(os.path.dirname(logFilePath))
logConfigFile = os.path.join(rootDirectory, 'config', 'logConfig.py')
f = open(logConfigFile, 'w+')
f.write(buf)
f.close()
def setupHostConfig(serverId, IPaddr, port):
# serverId = raw_input("Server ID: ")
# IPaddr = raw_input("IP address of this host: ")
# port = raw_input("Port to run this service: ")
hostConfigFilePath = os.path.join(rootDirectory, 'config', 'host.py')
buf = "# DO NOT EDIT THIS FILE BY HAND. AUTO GENERATED FROM SETUP\n" + \
"HOST_ID='"+serverId+"'\n"+\
"HOST_IP='"+IPaddr+"'\n"+\
"HOST_PORT="+port+"\n"
if not os.path.exists(os.path.dirname(hostConfigFilePath)):
os.makedirs(os.path.dirname(hostConfigFilePath))
f = open(hostConfigFilePath, 'w+')
f.write(buf)
f.close()
if __name__ == '__main__':
setupLogConfig()
setupHostConfig(sys.argv[1], sys.argv[2], sys.argv[3])