next up previous contents index
Next: 15.6 Built-in Module macfs
Up: 15.5 Built-in Module macdnr
Previous: 15.5 Built-in Module macdnr
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. 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)
guido@cnri.reston.va.us