2.4.1 DNR Result Objects

Since the DNR calls all execute asynchronously you do not get the results back immediately. Instead, you get a dnr result object. You can check this object to see whether the query is complete, and access its attributes to obtain the information when it is.

Alternatively, you can also reference the result attributes directly, this will result in an implicit wait for the query to complete.

The rtnCode and cname attributes are always available, the others depend on the type of query (address, hinfo or mx).

wait()
Wait for the query to complete.

isdone()
Return 1 if the query is complete.

rtnCode
The error code returned by the query.

cname
The canonical name of the host that was queried.

ip0
ip1
ip2
ip3
At most four integer IP addresses for this host. Unused entries are zero. Valid only for address queries.

cpuType
osType
Textual strings giving the machine type an OS name. Valid for ``hinfo'' queries.

exchange
The name of a mail-exchanger host. Valid for ``mx'' queries.

preference
The preference of this mx record. Not too useful, since the Macintosh will only return a single mx record. Valid for ``mx'' queries only.

The simplest way to use the module to convert names to dotted-decimal strings, without worrying about idle time, etc:

>>> def gethostname(name):
...     import macdnr
...     dnrr = macdnr.StrToAddr(name)
...     return macdnr.AddrToStr(dnrr.ip0)
See About this document... for information on suggesting changes.