mirror of
https://github.com/openkmip/pykmip
synced 2026-01-04 17:43:51 +00:00
Add client support for custom configuration file paths
This change adds client support for setting custom configuration file paths, allowing users and developers to place their settings file wherever they want. All client demo scripts have been updated to support a '-s' flag that can be used to set the configuration file for the demo. Client unit tests have also been updated to include this change.
This commit is contained in:
@@ -45,15 +45,20 @@ class ConfigHelper(object):
|
||||
# Timeout measured in seconds
|
||||
DEFAULT_TIMEOUT = 30
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, path=None):
|
||||
self.logger = logging.getLogger(__name__)
|
||||
|
||||
self.conf = SafeConfigParser()
|
||||
if self.conf.read(CONFIG_FILE):
|
||||
self.logger.debug("Using config file at {0}".format(CONFIG_FILE))
|
||||
|
||||
filenames = path
|
||||
if not path:
|
||||
filenames = CONFIG_FILE
|
||||
|
||||
if self.conf.read(filenames):
|
||||
self.logger.debug("Using config file at {0}".format(filenames))
|
||||
else:
|
||||
self.logger.warning(
|
||||
"Config file {0} not found".format(CONFIG_FILE))
|
||||
"Config file {0} not found".format(filenames))
|
||||
|
||||
def get_valid_value(self, direct_value, config_section,
|
||||
config_option_name, default_value):
|
||||
|
||||
Reference in New Issue
Block a user