Fix get_option() bug when option value type is bool.

Fix get_option() bug when option value type is bool.
Also, 'debug' should be default = 'False' for deployment.

Change-Id: Ic7b4defd774fd90b261d4f617ce2b783309d5b5c
Signed-off-by: Andy Yan <yanchao3@lenovo.com>
This commit is contained in:
Andy Yan 2017-01-03 14:45:53 +08:00
parent e93f85ae82
commit e83c8ffb73
2 changed files with 8 additions and 6 deletions

View File

@ -3,7 +3,7 @@
log_level= debug
#Server log settings
debug=True
debug=False
# Log to this file. Make sure the user running rsc has
# permissions to write to this file!

View File

@ -22,18 +22,20 @@ import logging
from six.moves import configparser
def get_option(section, key, default, type=str):
def get_option(section, key, default, value_type=str):
"""Function to support default values
Though config fallback feature could be used
Py 2.7 doesnt support it
"""
if config.has_option(section, key):
return type(config.get(section, key))
option_value = config.get(
section, key) if config.has_option(
section, key) else default
if value_type == bool:
return False if str(option_value).lower() == 'false' else True
else:
return type(default)
return value_type(option_value)
PROJECT_NAME = 'valence'