Skip to content
Snippets Groups Projects
Commit 964dc1f9 authored by ptangu01's avatar ptangu01
Browse files

improve :-) config

git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/trunk@1046 b32b6428-25c9-4566-ad07-03861ab6144f
parent c9545856
No related branches found
No related tags found
No related merge requests found
......@@ -49,34 +49,36 @@ def loadConfig(filename,confDir):
if cfg == None:
cfg = xAAL.tools.newDefaultConfigFile(configFile,__name__)
addr = xAAL.tools.getRandomUUID()
ipAddr = "localhost"
portAddr = "8080"
hostaddr = "localhost"
portaddr = "8080"
cfg.add_section('restapi')
cfg.set('restapi','xaaladdr',addr)
cfg.set('restapi','ipaddr',ipAddr)
cfg.set('restapi','portaddr',portAddr)
cfg.set('restapi','hostaddr',hostaddr)
cfg.set('restapi','portaddr',portaddr)
cfg.set('restapi','logfile','')
cfg.set('restapi','loglevel','debug')
cfg.set('restapi','dbname','/tmp/xaalrestapi_cache.db')
cfg.write(open(configFile,'w'))
xaaladdr = cfg.get('restapi','xaaladdr')
ipaddr = cfg.get('restapi','ipaddr')
hostaddr = cfg.get('restapi','hostaddr')
portaddr = cfg.get('restapi','portaddr')
logfile = cfg.get('restapi','logfile')
loglevel = cfg.get('restapi','loglevel')
dbname = cfg.get('restapi','dbname')
logger = xAAL.tools.getLogger(__name__,loglevel.upper(),'%s.log'%logfile)
logger.info("Config. file loaded : %s" % configFile)
logger.info("Log filename : %s" % logfile)
logger.info("db cache filename : %s" % dbname)
return xaaladdr,ipaddr,portaddr
return xaaladdr,hostaddr,portaddr,dbname
def run(filename='xaalrestapi',confDir=xAAL.config.CONF_DIR):
xaaladdr,ipaddr,portaddr = loadConfig(filename,confDir)
xaaladdr,hostaddr,portaddr,dbname = loadConfig(filename,confDir)
dbname = 'test.db'
dev = device.XAALBrowser(xaaladdr,dbname)
dev.setAlivePeriod(100)
......@@ -94,12 +96,15 @@ def run(filename='xaalrestapi',confDir=xAAL.config.CONF_DIR):
apisender = cherrypyrestapi.Sender(eng,dev)
apinotifications = cherrypyrestapi.Notifications(dev)
# # To configure server and engine
# cherrypy.config.update({'environment': 'production',
# 'log.error_file': 'restapi.log',
# 'log.screen':True,
# })
#
# To configure server and engine
cherrypy.config.update({'environment': 'production',
'log.screen': False,
'log.error_file': '',
'log.access_file': '',
'server.socket_host': hostaddr,
'server.socket_port': int(portaddr),
})
# To configure apps
conf={'/':
{'request.dispatch': cherrypy.dispatch.MethodDispatcher()},
......
[restapi]
xaaladdr =
ipaddr = localhost
portaddr = 8080
hostaddr = localhost
portaddr = 9000
logfile =
loglevel = debug
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment