config file erstellt

*Die Konfigutation ist in der Datei config/ems.conf gespeichert
*readConf() liest diese Datei ein und gibt sie als dict zurück
This commit is contained in:
Philipp Rauch 2013-11-21 18:06:51 +01:00
parent f0686090ec
commit b205714658
2 changed files with 38 additions and 0 deletions

24
scr/config.py Normal file
View file

@ -0,0 +1,24 @@
'''
Created on 21.11.2013
@author: rauchp
'''
def readConf():
confFile = open("config\ems.conf", "r")
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 readConf()

14
scr/config/ems.conf Normal file
View file

@ -0,0 +1,14 @@
#### DATENBANK ####
mySQL_server = localhost
mySQL_port = 3306 # default 3306
mySQL_user = smoke
mySQL_pass = KiWujcafAlor
mySQL_database = smoke_test
mySQL_table = battery
#### FLASK ####
flask_server = 0.0.0.0 # 0.0.0.0 for public access
flask_port = 5000
flask_debug = False # currently not used