def parse_config(filename):
    """
    Parse input file into config dictionary. For each section in the input file it will create a key
    with the value being a dictionary of key value pairs of options from that section.
    """
    if not os.path.exists(filename):
        raise ConfigError('Config file does not exist.')
    parser = ConfigParser.RawConfigParser()
    parser.read(filename)
    cfg = {}
    for section in parser.sections():
        cfg[section] = dict(parser.items(section))
    return cfg
Esempio n. 2
0
def init():
    '''
    method to parse global conf

    return Configdictionary
    '''
    confname = os.path.join(os.getcwd(), '..', 'global.conf')

    cDict = {}
    parser = SafeConfigParser()
    parser.read(confname)
    for section_name in parser.sections():
        for name, value in parser.items(section_name):
            cDict[name] = value

    logger.info('\033[31m Global Configuration %s \033[0m \n' % (cDict))
    return cDict
Esempio n. 3
0
def read_main_conf(config_file):
    options = {}
    parser = SafeConfigParser()
    fd = open(config_file, 'r')
    parser.readfp(fd)
    fd.close()

    sec = parser.sections()
    # we'll read "generic" for db information and "r" for start_date and "bicho" for backend
    for s in sec:
        if not(s in ["generic","r","bicho","bicho_1"]):
            continue
        options[s] = {}
        opti = parser.options(s)
        for o in opti:
            options[s][o] = parser.get(s, o)
    return options
Esempio n. 4
0
def read_main_conf(config_file):
    options = {}
    parser = SafeConfigParser()
    fd = open(config_file, 'r')
    parser.readfp(fd)
    fd.close()

    sec = parser.sections()
    # we'll read "generic" for db information and "r" for start_date and "bicho" for backend
    for s in sec:
        if not (s in ["generic", "r", "bicho", "bicho_1"]):
            continue
        options[s] = {}
        opti = parser.options(s)
        for o in opti:
            options[s][o] = parser.get(s, o)
    return options