[python-win32] network/internet info?

Tim Golden mail at timgolden.me.uk
Tue Apr 13 10:24:22 CEST 2010

On 13/04/2010 03:31, Alex Hall wrote:
> 1. current network connection type (ethernet, wifi, bluetooth, whatever).
> 2. Current up/down speed (such as 200kb up, 100kb down) for the
> current internet connection
> 4. MAC address of currently active connection

(Note there can be more than one network connection active...)

import wmi

c = wmi.WMI ()
for nic in c.Win32_NetworkAdapterConfiguration (IPEnabled=True):
   print nic

   for perf in c.Win32_PerfRawData_Tcpip_NetworkInterface (Name=nic.Description):
     print perf


> 3. Is there an active internet connection, or is access local only?
> Basically, the status that shows up in your system tray when you have
> the network icon showing.
> 5. For wifi, encryption status, radio type (of the router, not of the
> computer's adapter), signal strength.

Not sure about these, I'm afraid. The surest way to test "3" (active internet
connection) is to connect to some known address. Your local network can
have any configuration you like, so it's up to you to define "internet". eg:

import socket

   socket.socket ().connect (("#known web server#", 80))
except socket.error:
   print "could not connect"
   print "could connect"



More information about the python-win32 mailing list