'Gets all the information from the profile and stores it in the
w3af core plugins / target attributes for later use.
:raise BaseFrameworkException: if the profile to load has some type of
problem, or the plugins are incorrectly
configured.'

def use_profile(self, profile_name, workdir=None):

    error_messages = []
    self._w3af_core.plugins.zero_enabled_plugins()
    MiscSettings().set_default_values()
    self._w3af_core.uri_opener.settings.set_default_values()
    if (profile_name is None):
        return
    profile_inst = profile(profile_name, workdir)
    self._w3af_core.target.set_options(profile_inst.get_target())
    try:
        profile_misc_settings = profile_inst.get_misc_settings()
    except BaseFrameworkException as e:
        msg = 'Setting    the    framework    misc-settings    raised    an    exception    due    to    unknown    or    invalid    configuration    parameters.    %s'
        error_messages.append((msg % e))
    else:
        if ('local_ip_address' in profile_inst.get_misc_settings()):
            local_ip = get_local_ip()
            profile_misc_settings['local_ip_address'].set_value(local_ip)
        misc_settings = MiscSettings()
        misc_settings.set_options(profile_misc_settings)
    try:
        http_settings = profile_inst.get_http_settings()
    except BaseFrameworkException as e:
        msg = 'Setting    the    framework    http-settings    raised    an    exception    due    to    unknown    or    invalid    configuration    parameters.    %s'
        error_messages.append((msg % e))
    else:
        self._w3af_core.uri_opener.settings.set_options(http_settings)
    error_fmt = 'The    profile    you    are    trying    to    load    (%s)    seems    to    be    outdated,    this    is    a    common    issue    which    happens    when    the    framework    is    updated    and    one    of    its    plugins    adds/removes    one    of    the    configuration    parameters    referenced    by    a    profile,    or    the    plugin    is    removed    all    together.\n\nThe    profile    was    loaded    but    some    of    your    settings    might    have    been    lost.    This    is    the    list    of    issues    that    were    found:\n\n                -    %s\n\nWe    recommend    you    review    the    specific    plugin    configurations,    apply    the    required    changes    and    save    the    profile    in    order    to    update    it    and    avoid    this    message.    If    this    warning    does    not    disappear    you    can    manually    edit    the    profile    file    to    fix    it.'
    core_set_plugins = self._w3af_core.plugins.set_plugins
    for plugin_type in self._w3af_core.plugins.get_plugin_types():
        plugin_names = profile_inst.get_enabled_plugins(plugin_type)
        try:
            unknown_plugins = core_set_plugins(plugin_names, plugin_type, raise_on_error=False)
        except KeyError:
            msg = 'The    profile    references    the    "%s"    plugin    type    which    is    unknown    to    the    w3af    framework.'
            error_messages.append((msg % plugin_type))
            continue
        for unknown_plugin in unknown_plugins:
            msg = 'The    profile    references    the    "%s.%s"    plugin    which    is    unknown    in    the    current    framework    version.'
            error_messages.append((msg % (plugin_type, unknown_plugin)))
        for plugin_name in (set(plugin_names) - set(unknown_plugins)):
            try:
                plugin_options = profile_inst.get_plugin_options(plugin_type, plugin_name)
                self._w3af_core.plugins.set_plugin_options(plugin_type, plugin_name, plugin_options)
            except BaseFrameworkException as w3e:
                msg = 'Setting    the    options    for    plugin    "%s.%s"    raised    an    exception    due    to    unknown    or    invalid    configuration    parameters.    %s'
                error_messages.append((msg % (plugin_type, plugin_name, w3e)))
    if error_messages:
        msg = (error_fmt % (profile_name, '\n                -    '.join(error_messages)))
        raise BaseFrameworkException(msg)
