Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #5447 > unrolled thread

Re: Get the IP address of WIFI interface

Started byAndrew Berg <bahamutzero8825@gmail.com>
First post2011-05-15 16:14 -0500
Last post2011-05-15 18:42 -0700
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Get the IP address of WIFI interface Andrew Berg <bahamutzero8825@gmail.com> - 2011-05-15 16:14 -0500
    Re: Get the IP address of WIFI interface MrJean1 <mrjean1@gmail.com> - 2011-05-15 18:42 -0700

#5447 — Re: Get the IP address of WIFI interface

FromAndrew Berg <bahamutzero8825@gmail.com>
Date2011-05-15 16:14 -0500
SubjectRe: Get the IP address of WIFI interface
Message-ID<mailman.1601.1305494064.9059.python-list@python.org>
On 2011.05.15 06:12 AM, Tim Golden wrote:
> ... and for Windows:
>
> <code>
> import wmi
>
> for nic in wmi.WMI ().Win32_NetworkAdapterConfiguration (IPEnabled=1):
>    print nic.Caption, nic.IPAddress
>
> </code>
One thing I found out about Win32_NetworkAdapterConfiguration is that it
only contains /current/ information and not the stored info that it uses
when making an initial connection (you can see and edit this info in the
Network and Sharing Center applet). The difference is that if you're
offline, that WMI object will have no useful info at all. You can find
the info in the registry if you know what the UUID (or whatever it is)
of (or assigned to) the interface (it's in
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters\Interfaces).
The OP said the card would be connected, so it might not be an issue,
but I think it's important to know that. Wouldn't want you to suddenly
get blank strings or exceptions and not know why. ;-)

[toc] | [next] | [standalone]


#5456

FromMrJean1 <mrjean1@gmail.com>
Date2011-05-15 18:42 -0700
Message-ID<537d5138-2dc1-422a-8ebc-24a76270f2ce@k27g2000pri.googlegroups.com>
In reply to#5447
Perhaps, this recipe works for your case:

  <http://code.activestate.com/recipes/577191>

It does parse ifconfig and ipconfig, if found.

/Jean



On May 15, 2:14 pm, Andrew Berg <bahamutzero8...@gmail.com> wrote:
> On 2011.05.15 06:12 AM, Tim Golden wrote:> ... and for Windows:
>
> > <code>
> > import wmi
>
> > for nic in wmi.WMI ().Win32_NetworkAdapterConfiguration (IPEnabled=1):
> >    print nic.Caption, nic.IPAddress
>
> > </code>
>
> One thing I found out about Win32_NetworkAdapterConfiguration is that it
> only contains /current/ information and not the stored info that it uses
> when making an initial connection (you can see and edit this info in the
> Network and Sharing Center applet). The difference is that if you're
> offline, that WMI object will have no useful info at all. You can find
> the info in the registry if you know what the UUID (or whatever it is)
> of (or assigned to) the interface (it's in
> HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters\Inter faces).
> The OP said the card would be connected, so it might not be an issue,
> but I think it's important to know that. Wouldn't want you to suddenly
> get blank strings or exceptions and not know why. ;-)

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web