[Twisted-Python] Twisted.Names assistance with auth and additional sections

Sean Leach kickdaddy at gmail.com
Tue Mar 20 21:42:25 MDT 2007


Ok...ignore my last post, jumped the gun, the additional and authority
still don't exist in the result object.  In addition, I tried your
example to make sure I wasn't crazy, and it doesn't return any result
data.  I know it's not a network issue or anything silly as I can
query a.root fine with dig and get the results.  Here is the session:

$ cat test.py
#!/usr/bin/python2.4
import time
from twisted.names import dns, client, _version
print _version.version
def errorHandler(error):
    print str(error)
r = client.Resolver(servers=[('198.41.0.4', 53)])
d = r.queryUDP([dns.Query('google.com', dns.IN,
dns.A)]).addErrback(errorHandler)
time.sleep(5)  ## give it a time for shitz and giggles
print d
print d.result

$ ./test.py
[twisted.names, version 0.4.0]
<Deferred at 0xB7BBBFECL>
Traceback (most recent call last):
  File "./test.py", line 10, in ?
    print d.result
AttributeError: Deferred instance has no attribute 'result'






On 3/20/07, Sean Leach <kickdaddy at gmail.com> wrote:
> Sweet!  That was it.  Explicitly creating the Resolver worked like a
> charm (don't ask me why :)   ).  Thanks!
>
> On 3/20/07, Jean-Paul Calderone <exarkun at divmod.com> wrote:
> > On Tue, 20 Mar 2007 16:13:14 -0700, Sean Leach <kickdaddy at gmail.com> wrote:
> > >Thanks Jean-Paul,
> > >
> > >I tried changing to queryUDP, and it just sits there, never sends out
> > >a query (watching with tcpdump).  If I change it to _lookup, which it
> > >looks like queryUDP calls, it sends the query, but like lookupAddress,
> > >I don't get the additional and auth sections still...
> > >
> > >What is weird, when I do this
> > >
> > >deferred = resolver.queryUDP([Dns.Query(name, dns.IN, dns.A)])
> > >
> > >and I try and debug why it's hanging, I put a print in the
> > >ResolverBase.queryUDP function right at the top, and it never prints.
> > >
> >
> > The factoring here is a little weird.  Try creating a t.names.client.Resolver
> > explicitly (just instantiate it with a servers list or a resolv.conf filename)
> > and calling queryUDP on it (unless you were doing this already).  The
> > createResolver function does some other stuff which might be getting in the
> > way here, either of functioning or debugging.
> >
> > Here's an example (using t/conch/stdio.py):
> >
> >   >>> from twisted.names import dns, client
> >   >>> r = client.Resolver(servers=[('198.41.0.4', 53)])
> >   >>> d = r.queryUDP([dns.Query('google.com', dns.IN, dns.A)])
> >   >>> d
> >   <Deferred at 0xB78F072CL  current result: <twisted.names.dns.Message instance at 0xb79b6aec>>
> >   >>> d.result
> >   <twisted.names.dns.Message instance at 0xb79b6aec>
> >   >>> d.result.authority
> >   [<snip - a bunch of records>]
> >   >>> d.result.additional
> >   [<snip - a bunch of records>]
> >   >>> d.result.answers
> >   []
> >   >>>
> >
> > Hope this helps things,
> >
> > Jean-Paul
> >
> > _______________________________________________
> > Twisted-Python mailing list
> > Twisted-Python at twistedmatrix.com
> > http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
> >
>




More information about the Twisted-Python mailing list