def nmap_scan():
<EOL>hs = HostSearch()<EOL>config = Config()<EOL>nmap_types = ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT:all>']<EOL>options = {'<STR_LIT>':'<STR_LIT>', '<STR_LIT>':'<STR_LIT>', '<STR_LIT>': config.get('<STR_LIT>', '<STR_LIT>'), '<STR_LIT>': '<STR_LIT>', '<STR_LIT:all>': '<STR_LIT>'}<EOL>hs_parser = hs.argparser<EOL>argparser = argparse.ArgumentParser(parents=[hs_parser], conflict_handler='<STR_LIT>',description="<STR_LIT>")<EOL>argparser.add_argument('<STR_LIT:type>', metavar='<STR_LIT:type>',help='<STR_LIT>',type=str, choices=nmap_types, default='<STR_LIT>', const='<STR_LIT>', nargs='<STR_LIT:?>')<EOL>arguments, extra_nmap_args = argparser.parse_known_args()<EOL>tags = nmap_types[nmap_types.index(arguments.type):]<EOL>tags = ["<STR_LIT>" + tag  for tag in tags]<EOL>hosts = hs.get_hosts(tags=tags)<EOL>hosts = [host for host in hosts]<EOL>nmap_args = []<EOL>nmap_args.extend(extra_nmap_args)<EOL>nmap_args.extend(options[arguments.type].split('<STR_LIT:U+0020>'))<EOL>print_notification("<STR_LIT>".format(nmap_args, len(hosts)))<EOL>if len(hosts):<EOL><INDENT>result = nmap(nmap_args, [str(h.address) for h in hosts])<EOL>for host in hosts:<EOL><INDENT>host.add_tag("<STR_LIT>".format(arguments.type))<EOL>host.save()<EOL><DEDENT>print_notification("<STR_LIT>")<EOL>stats = import_nmap(result, "<STR_LIT>".format(arguments.type), check_function=all_hosts, import_services=True)<EOL>stats['<STR_LIT>'] = len(hosts)<EOL>stats['<STR_LIT:type>'] = arguments.type<EOL>Logger().log('<STR_LIT>', "<STR_LIT>".format(arguments.type, len(hosts)), stats)<EOL><DEDENT>else:<EOL><INDENT>print_notification("<STR_LIT>")<EOL><DEDENT>
Scans the given hosts with nmap.