def dns_check(name, uuid):
    resolver = dns.resolver.Resolver()
    resolver.timeout = 3
    # get nameservers list (max 4)
    try:
        ns_list = resolver.query(name, 'NS')
    except:
        ns_list = []
    if len(ns_list) > 4:
        ns_list = ns_list[0:4]
    servers = []
    for ns in ns_list:
        ns = str(ns)
        #print ns
        servers.append(str(resolver.query(ns, 'A')[0]))
    if servers:
        resolver.nameservers = servers

    parts = name.split('.')

    while len(parts) > 1:
        try:
            print '.'.join(parts)
            txt_list = resolver.query('.'.join(parts), 'TXT')
            for txt in txt_list:
                if 'uwsgi:%s' % uuid in str(txt):
                    return True
        except:
            pass
        parts = parts[1:]
    return False
dataset/ETHPy150Open unbit/uwsgi.it/uwsgi_it_api/uwsgi_it_api/utils.py/dns_check/original