'It calls the "main" from hmap and writes the results to the kb.
:param fuzzable_request: A fuzzable_request instance that contains
(among other things) the URL to test.'

@runonce(exc_class=RunOnce)
def discover(self, fuzzable_request):

    msg = 'Hmap    web    server    fingerprint    is    starting,    this    may    take    a    while.'
    om.out.information(msg)
    url = fuzzable_request.get_url()
    protocol = url.get_protocol()
    server = url.get_net_location()
    if (protocol == 'https'):
        port = 443
        ssl = True
    else:
        port = 80
        ssl = False
    if server.count(':'):
        port = int(server.split(':')[1])
        server = server.split(':')[0]
    try:
        results = originalHmap.testServer(ssl, server, port, 1, self._gen_fp)
    except BaseFrameworkException as w3:
        msg = 'A    BaseFrameworkException    occurred    while    running    hmap:    "%s"'
        om.out.error((msg % w3))
    except Exception as e:
        msg = 'An    unhandled    exception    occurred    while    running    hmap:    "%s"'
        om.out.error((msg % e))
    else:
        if len(results):
            server = results[0]
            desc = 'The    most    accurate    fingerprint    for    this    HTTP    server    is:    "%s".'
            desc = (desc % server)
            i = Info('Webserver    fingerprint', desc, 1, self.get_name())
            i['server'] = server
            om.out.information(i.get_desc())
            kb.kb.append(self, 'server', i)
            kb.kb.raw_write(self, 'server_string', server)
        if self._gen_fp:
            msg = 'Hmap    fingerprint    file    generated,    please    send    a    mail    to    w3af-develop@lists.sourceforge.net    including    the    fingerprint    file,    your    name    and    what    server    you    fingerprinted.    New    fingerprints    make    the    hmap    plugin    more    powerfull    and    accurate.'
            om.out.information(msg)
