notifly/server.py
def load_config(config_file=None):
    """
    Parse config file and load parameters from CLI
    the config file is always leading
    """
    params = parameter_parser()
    if params.conf:
        conf_file = parse_config_file(params.conf)
    else:
        if config_file:
            conf_file = parse_config_file(config_file)
    try:
        local_ip = conf_file['net']['local_ip']
    except KeyError:
        local_ip = None
    try:
        local_port = int(conf_file['net']['local_port'])
    except KeyError:
        local_port = None
    except ValueError:
        raise ConfigError("local_port is not a number")
    try:
        accept_from = conf_file['net']['accept_from']
    except KeyError:
        accept_from = None
    try:
        endpoints = conf_file['endpoints']
    except KeyError:
        endpoints = None
    try:
        event_batch_size = int(conf_file['general']['event_batch_size'])
    except KeyError:
        event_batch_size = None
    except ValueError:
        raise ConfigError("event_batch_size must be a number")
    try:
        workers = int(conf_file['general']['workers'])
    except ValueError:
        raise ConfigError("workers must be a number")
    except KeyError:
        workers = None
    if not local_ip:
        local_ip = params.local_ip
    if not local_port:
        try:
            local_port = int(params.local_port)
        except ValueError:
            raise ConfigError("local_port must be a number")
    if not workers:
        try:
            workers = int(params.workers)
        except ValueError:
            raise ConfigError("workers must be a number")
    if not event_batch_size:
        event_batch_size = params.event_batch_size
    return {
        'local_port' : local_port,
        'local_ip' : local_ip,
        'accept_from' : accept_from,
        'workers' : workers,
        'event_batch_size' : event_batch_size,
        'endpoints' : endpoints
    }

    Parse config file and load parameters from CLI
    the config file is always leading
    
Parse config file and load parameters from CLI
the config file is always leading
Parse config file and load parameters from CLI the config file is always leading
def load_config(config_file=None):
    params = parameter_parser()
    if params.conf:
        conf_file = parse_config_file(params.conf)
    else:
        if config_file:
            conf_file = parse_config_file(config_file)
    try:
        local_ip = conf_file['net']['local_ip']
    except KeyError:
        local_ip = None
    try:
        local_port = int(conf_file['net']['local_port'])
    except KeyError:
        local_port = None
    except ValueError:
        raise ConfigError("local_port is not a number")
    try:
        accept_from = conf_file['net']['accept_from']
    except KeyError:
        accept_from = None
    try:
        endpoints = conf_file['endpoints']
    except KeyError:
        endpoints = None
    try:
        event_batch_size = int(conf_file['general']['event_batch_size'])
    except KeyError:
        event_batch_size = None
    except ValueError:
        raise ConfigError("event_batch_size must be a number")
    try:
        workers = int(conf_file['general']['workers'])
    except ValueError:
        raise ConfigError("workers must be a number")
    except KeyError:
        workers = None
    if not local_ip:
        local_ip = params.local_ip
    if not local_port:
        try:
            local_port = int(params.local_port)
        except ValueError:
            raise ConfigError("local_port must be a number")
    if not workers:
        try:
            workers = int(params.workers)
        except ValueError:
            raise ConfigError("workers must be a number")
    if not event_batch_size:
        event_batch_size = params.event_batch_size
    return {
        'local_port' : local_port,
        'local_ip' : local_ip,
        'accept_from' : accept_from,
        'workers' : workers,
        'event_batch_size' : event_batch_size,
        'endpoints' : endpoints
    }
def load_config ( config_file = None ) : params = parameter_parser ( ) if params . conf : conf_file = parse_config_file ( params . conf ) else : if config_file : conf_file = parse_config_file ( config_file ) try : local_ip = conf_file [ 'net' ] [ 'local_ip' ] except KeyError : local_ip = None try : local_port = int ( conf_file [ 'net' ] [ 'local_port' ] ) except KeyError : local_port = None except ValueError : raise ConfigError ( "local_port is not a number" ) try : accept_from = conf_file [ 'net' ] [ 'accept_from' ] except KeyError : accept_from = None try : endpoints = conf_file [ 'endpoints' ] except KeyError : endpoints = None try : event_batch_size = int ( conf_file [ 'general' ] [ 'event_batch_size' ] ) except KeyError : event_batch_size = None except ValueError : raise ConfigError ( "event_batch_size must be a number" ) try : workers = int ( conf_file [ 'general' ] [ 'workers' ] ) except ValueError : raise ConfigError ( "workers must be a number" ) except KeyError : workers = None if not local_ip : local_ip = params . local_ip if not local_port : try : local_port = int ( params . local_port ) except ValueError : raise ConfigError ( "local_port must be a number" ) if not workers : try : workers = int ( params . workers ) except ValueError : raise ConfigError ( "workers must be a number" ) if not event_batch_size : event_batch_size = params . event_batch_size return { 'local_port' : local_port , 'local_ip' : local_ip , 'accept_from' : accept_from , 'workers' : workers , 'event_batch_size' : event_batch_size , 'endpoints' : endpoints }
Parse config file and load parameters from CLI
the config file is always leading
Parse config file and load parameters from CLI the config file is always leading
"""
    Parse config file and load parameters from CLI
    the config file is always leading
    """
config_file