diff --git a/confluent_server/confluent/config/conf.py b/confluent_server/confluent/config/conf.py index 80bf032f..aeca1cd6 100644 --- a/confluent_server/confluent/config/conf.py +++ b/confluent_server/confluent/config/conf.py @@ -15,12 +15,13 @@ # limitations under the License. -#This defines config variable to store the global configuration for confluent +# This defines config variable to store the global configuration for confluent import ConfigParser import os _config = None + def init_config(): global _config configfile = "/etc/confluent/service.cfg" @@ -30,25 +31,39 @@ def init_config(): _config = ConfigParser.ConfigParser() _config.read(configfile) + def get_config(): + if _config is None: + init_config() return _config + def get_int_option(section, option): + if _config is None: + init_config() try: return _config.getint(section, option) except ( - ConfigParser.NoSectionError, ConfigParser.NoOptionError, ValueError): + ConfigParser.NoSectionError, ConfigParser.NoOptionError, + ValueError): return None + def get_boolean_option(section, option): + if _config is None: + init_config() try: return _config.getboolean(section, option) except ( - ConfigParser.NoSectionError, ConfigParser.NoOptionError, ValueError): + ConfigParser.NoSectionError, ConfigParser.NoOptionError, + ValueError): return None + def get_option(section, option): + if _config is None: + init_config() try: return _config.get(section, option) except (ConfigParser.NoSectionError, ConfigParser.NoOptionError): - return None + return None \ No newline at end of file