Load handlers

def load_handlers(config, handler_names):
    """
    Load handlers
    """

    handlers = []

    if isinstance(handler_names, basestring):
        handler_names = [handler_names]

    for handler in handler_names:
        logger.debug('Loading Handler %s', handler)
        try:
            # Load Handler Class
            cls = load_dynamic_class(handler, Handler)
            cls_name = cls.__name__

            # Initialize Handler config
            handler_config = configobj.ConfigObj()
            # Merge default Handler default config
            handler_config.merge(config['handlers']['default'])
            # Check if Handler config exists
            if cls_name in config['handlers']:
                # Merge Handler config section
                handler_config.merge(config['handlers'][cls_name])

            # Check for config file in config directory
            if 'handlers_config_path' in config['server']:
                configfile = os.path.join(
                    config['server']['handlers_config_path'],
                    cls_name) + '.conf'
                if os.path.exists(configfile):
                    # Merge Collector config file
                    handler_config.merge(configobj.ConfigObj(configfile))

            # Initialize Handler class
            h = cls(handler_config)
            handlers.append(h)

        except (ImportError, SyntaxError):
            # Log Error
            logger.warning("Failed to load handler %s. %s",
                           handler,
                           traceback.format_exc())
            continue

    return handlers