adns-python return codes

Sion Arrowsmith siona at chiark.greenend.org.uk
Thu Sep 9 08:48:13 EDT 2004


Sion Arrowsmith  <siona at chiark.greenend.org.uk> wrote:
>Josh Close  <narshe at gmail.com> wrote:
>>Does anyone know what the return codes for an mx adns python lookup
>>are? I know 0 means a valid domain, and anything else isn't, but there
>>are "no nameservers found" and "timeout" and other things that would
>>have to be retried again.
>
>I'd guess you want to be looking at adns.h, specifically the typedef'd
>enum adns_status (ll. 205--255 in the copy I'm looking at), although
>I've not looked at how the Python bindings to adns work.

I now *have* looked at the Python bindings to adns -- if you're
after "what error code corresponds to a given error?" then
adns.status exposes the adns_status enum:

>>> adns.status.timeout
30

although if what you're interested in is when to retry then you
might be better off using adns.exception() and catching and
handling the different classes of exception appropriately.

If you want a human-readable description of a given status code,
it looks like the best way would be:

try:
    adns.exception(result[0])
except adns.Error, e:
    description = e[1]

-- 
\S -- siona at chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/
  ___  |  "Frankly I have no feelings towards penguins one way or the other"
  \X/  |    -- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump



More information about the Python-list mailing list