ems/scr/config.py
Philipp Rauch e70ef4de38 Config auf Module angewand
*die readConf wurde verbessert
*Standartwerte wurden hinterlegt
*In den Modulen wird das Configfile verwendet
2013-11-21 18:11:38 +01:00

45 lines
No EOL
1.2 KiB
Python

'''
Created on 21.11.2013
@author: rauchp
'''
confDic = {
'mySQL_server': 'localhost',
'mySQL_port': '3306',
'mySQL_user': 'smoke',
'mySQL_pass': 'KiWujcafAlor',
'mySQL_database': 'smoke_test',
'mySQL_table': 'battery',
'flask_server': '0.0.0.0',
'flask_port': '5000',
'flask_debug': False,
}
def readConf():
try:
confFile = open("config\ems.conf", "r")
error = False
except IOError:
error = True
if error:
confDic.update({'error' : 'config/ems.conf not found'})
return confDic
for line in confFile:
line = line.strip()
if len(line) > 0 and not line[0] == "#":
ident = line.split("=")
for i in range(len(ident)):
ident[i] = ident[i].strip()
val = ident[1].split("#") #cut off comments
val[0] = val[0].strip()
val[0] = True if val[0] == 'True' else val[0]
val[0] = False if val[0] == 'False' else val[0]
confDic[ident[0]] = val[0]
confFile.close()
return confDic
print 'config:\t', readConf()