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:
parent
e93f85ae82
commit
e83c8ffb73
@ -3,7 +3,7 @@
|
|||||||
log_level= debug
|
log_level= debug
|
||||||
|
|
||||||
#Server log settings
|
#Server log settings
|
||||||
debug=True
|
debug=False
|
||||||
|
|
||||||
# Log to this file. Make sure the user running rsc has
|
# Log to this file. Make sure the user running rsc has
|
||||||
# permissions to write to this file!
|
# permissions to write to this file!
|
||||||
|
@ -22,18 +22,20 @@ import logging
|
|||||||
from six.moves import configparser
|
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
|
"""Function to support default values
|
||||||
|
|
||||||
Though config fallback feature could be used
|
Though config fallback feature could be used
|
||||||
Py 2.7 doesnt support it
|
Py 2.7 doesnt support it
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if config.has_option(section, key):
|
option_value = config.get(
|
||||||
return type(config.get(section, key))
|
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:
|
else:
|
||||||
return type(default)
|
return value_type(option_value)
|
||||||
|
|
||||||
|
|
||||||
PROJECT_NAME = 'valence'
|
PROJECT_NAME = 'valence'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user