On Monday, 30 September 2013 14:36:34 UTC+2, William Ray Wing  wrote:
> On Sep 30, 2013, at 7:42 AM, Michel Albert <***> wrote:
> 
> 
> 
> > Hi,
> 
> > 
> 
> > ``socket.gethostbyname`` sends the DNS resolution query to the DNS server 
> > specified by the OS. Is there an easy way to send a query to a *different* 
> > server?
> 
> > 
> 
> > I see that twisted.names allows you to do this, but, having all of twisted 
> > as dependency to my project when all I need to do is a simple DNS query 
> > seems a bit extreme. I also found pydns, but that looks fairly outdated and 
> > unmaintained.
> 
> > 
> 
> > Is there not an actively maintained lightweight solution? If not, I will go 
> > with twisted.
> 
> > 
> 
> > 
> 
> > Cheers,
> 
> > Mich.
> 
> > -- 
> 
> > https://mail.python.org/mailman/listinfo/python-list
> 
> 
> 
> It isn't pure python, but you would be pretty much guaranteed a maintained 
> solution if you use the name server lookup in your OS.  Something like:
> 
> 
> 
>       import subprocess
> 
>       nsl_reslt = subprocess.Popen(['nslookup', '<insert name nere>' ],stderr 
> = subprocess.PIPE, stdout = subprocess.PIPE).communicate()[0]
> 
> 
> 
> 
> 
> Hope this helps,
> 
> Bill

Hmm... I had this option in mind, but opening a subprocess for something as 
small as this seemed a bit error-prone. If something on the system changes, 
nslookup replaced by dig or nslookup output changes for example your 
application will bug out.

Granted, the chance of this happening is slim, but using a fixed-version 
dependency in your setup script gives you a much safer solution IMO.

I know I may be splitting hairs. Any of the mentioned solutions are fine. But I 
am curious to see if something like this is not yet implemented in a more 
standard way. I was surprised to see that ``gethostbyname`` does not take an 
optional parameter for this task.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to