[python-win32] Fetching network interface instance names

Schollnick, Benjamin Benjamin.Schollnick at xerox.com
Mon Jul 25 15:11:52 CEST 2005


Weird, must be a difference between ActiveState & Standard Python....

Hmmm....  I wonder what else is different...

		- Benjamin

> -----Original Message-----
> From: Simon Dahlbacka [mailto:simon.dahlbacka at gmail.com] 
> Sent: Monday, July 25, 2005 9:08 AM
> To: Schollnick, Benjamin
> Cc: Mark Hammond; Chris Miles; python-win32 at python.org
> Subject: Re: [python-win32] Fetching network interface instance names
> 
> 
> WorksForMe both 2.3.2 and 2.4.1  (ActiveState versions) 
> (actually I only tried the .Caption, but since you said that 
> that also failed..)
> 
> 
> 
> On 7/25/05, Schollnick, Benjamin 
> <Benjamin.Schollnick at xerox.com> wrote:
> > > http://www.microsoft.com/technet/scriptcenter/scripts/python/p
> > > yindex.mspx
> > > has some scripts that appear to do what you need.
> > >
> > > (Quite cool that we can now post a microsoft.com address for help 
> > > with Python scripts ;)
> > 
> > Except that they do not seem to work.... I have tried three so far, 
> > and they all fail with object has no attribute errors...
> > 
> > Either that, or there is a significant difference with 
> ActiveState & 
> > standard Python 2.4.1 with the Win32all extensions...  (I don't 
> > remember a significant difference...
> > I have previously used ActivateState back in the v2.0 / 
> v2.1 days...)
> > 
> > For example...
> > 
> > def windows_installed_software ( host_computer = "."):
> >     import win32com.client
> >     strComputer = host_computer
> >     objWMIService =
> > win32com.client.Dispatch("WbemScripting.SWbemLocator")
> >     objSWbemServices =
> > objWMIService.ConnectServer(strComputer,"root\cimv2")
> >     colItems = objSWbemServices.ExecQuery("Select * from 
> Win32_Product")
> >     for objItem in colItems:
> >         print "Caption: ", objItem.Caption
> >         print "Description: ", objItem.Description
> >         print "Identifying Number: ", objItem.IdentifyingNumber
> >         print "Install Date: ", objItem.InstallDate
> >         print "Install Date 2: ", objItem.InstallDate2
> >         print "Install Location: ", objItem.InstallLocation
> >         print "Install State: ", objItem.InstallState
> >         print "Name: ", objItem.Name
> >         print "Package Cache: ", objItem.PackageCache
> >         print "SKU Number: ", objItem.SKUNumber
> >         print "Vendor: ", objItem.Vendor
> >         print "Version: ", objItem.Version
> > 
> >         They are obviously missing a step, because the colItems / 
> > ExecQuerry is working, but objItems does not have any of 
> the Caption / 
> > Description, etc variables....
> > 
> >         So there must be a missing step....
> > 
> >                 - Benjamin
> > >
> > > Mark.
> > >
> > > > -----Original Message-----
> > > > From: python-win32-bounces at python.org 
> > > > [mailto:python-win32-bounces at python.org]On Behalf Of Chris Miles
> > > > Sent: Monday, 25 July 2005 7:45 AM
> > > > To: python-win32 at python.org
> > > > Subject: [python-win32] Fetching network interface 
> instance names
> > > >
> > > >
> > > > Hi, I am querying win32pdh to fetch statistics from 
> each network 
> > > > interface on the machine.  I am able to fetch the stats I
> > > need, using
> > > > the code below, from each network interface, provided I
> > > already know
> > > > the network interface instance name (eg: intf below).
> > > >
> > > > My Q is: how can I programmatically find out what the network 
> > > > interface instance names are?
> > > >
> > > > I can see the instance names manually from the GUI using
> > > > win32pdhutil.browse() but that doesn't help my program do it.
> > > >
> > > >  >>> intf = 'Intel[R] PRO_100 Network Connection - Packet 
> > > > Scheduler Miniport'  >>> import win32pdh  >>> hq = 
> > > > win32pdh.OpenQuery()  >>> cp = win32pdh.MakeCounterPath( (None, 
> > > > 'Network
> > > Interface', intf,
> > > > None, -1, 'Bytes Sent/sec') )
> > > >  >>> hc = win32pdh.AddCounter( hq, cp )
> > > >  >>> type,val = win32pdh.GetFormattedCounterValue( hc, 
> > > > win32pdh.PDH_FMT_LONG )  >>> type
> > > > 272696320
> > > >  >>> val
> > > > 0
> > > >
> > > > Cheers,
> > > > Chris
> > > >
> > > > --
> > > > Chris Miles
> > > > http://chrismiles.info/
> > > >
> > > > _______________________________________________
> > > > Python-win32 mailing list
> > > > Python-win32 at python.org 
> > > > http://mail.python.org/mailman/listinfo/python-win32
> > >
> > > _______________________________________________
> > > Python-win32 mailing list
> > > Python-win32 at python.org 
> > > http://mail.python.org/mailman/listinfo/python-win32
> > >
> > _______________________________________________
> > Python-win32 mailing list
> > Python-win32 at python.org 
> > http://mail.python.org/mailman/listinfo/python-win32
> >
> 


More information about the Python-win32 mailing list