On 08/03/2010 02:38, pyt...@bdurham.com wrote:
I'm trying to get the Win32_PortableBattery and
Win32_SystemEnclosure classes to work.

Oddly enough, both classes return empty results on my laptop. I'm
wondering if I'm using the WMI interface correctly or if I need
to be more explict in the arguments I pass to each class's
__init__?

It looks like you're a little bit confused as to what's
going on here. (Or maybe I am :) ).

import wmi
c = wmi.WMI().Win32_SystemEnclosure
c
<_wmi_class: \\SONYLAPTOP-01\ROOT\cimv2:Win32_SystemEnclosure>

Although you *can*, you won't normally use the class
as an object in its own right. But maybe you were just
checking that you'd got the right thing.


c()
[<_wmi_object:
\\SONYLAPTOP-01\root\cimv2:Win32_SystemEnclosure.Tag="System
Enclosure 0">]

OK. So you've got a list (of length one) which is a Win32_SystemEnclosure
instance.


c()[0]
<_wmi_object:
\\SONYLAPTOP-01\root\cimv2:Win32_SystemEnclosure.Tag="System
Enclosure 0">

And the first item is indeed the System Enclosure

c()[0].properties
{u'HotSwappable': None, u'SKU': None, u'SerialNumber': None,
u'Width': None, u'SecurityBreach': None, u'Removable': None,
u'PartNumber': None, u'AudibleAlarm': None, u'Status': None,
u'TypeDescriptions': None, u'Description': None,
u'NumberOfPowerCords': None, u'Replaceable': None,
u'LockPresent': None, u'SecurityStatus': None,
u'BreachDescription': None, u'Manufacturer': None,
u'OtherIdentifyingInfo': None, u'Version': None, u'Name': None,
u'InstallDate': None, u'ServiceDescriptions': None,
u'VisibleAlarm': None, u'PoweredOn': None, u'ServicePhilosophy':
None, u'SMBIOSAssetTag': None, u'Caption': None, u'Depth': None,
u'Model': None, u'HeatGeneration': None, u'Weight': None,
u'ChassisTypes': None, u'Height': None, u'Tag': None,
u'CableManagementStrategy': None, u'CreationClassName': None,
u'CurrentRequiredOrProduced': None}

OK. Now you're looking at the behind-the-scenes properties
cache. Which doesn't have anything in it yet because you
haven't requested any properties. Try this instead:

<code>
import wmi

c = wmi.WMI ()
for enclosure in c.Win32_SystemEnclosure ():
  print enclosure

  # or print enclosure.SerialNumber, enclosure.ChassisTypes

</code>

Do you still get no values? And likewise for the battery class..

TJG
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to