[python-win32] Trying to get the Win32_PortableBattery and Win32_SystemEnclosure classes to work
python at bdurham.com
python at bdurham.com
Mon Mar 8 19:46:15 CET 2010
Hi Tim,
> It looks like you're a little bit confused as to what's going on here. (Or maybe I am :) ).
No, I'm definitely the one that's confused! :)
> 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.
I was checking that I got the right thing - for purposes of documenting
my question on this forum.
>>>> 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:
> Do you still get no values?
Now I see what I was doing wrong. Your code example explains it
perfectly.
Works perfectly for me with the ***c.Win32_SystemEnclosure class***.
> And likewise for the battery class
No. The battery class appears to really return no information.
Here's my updated battery code:
import wmi
c = wmi.WMI()
for battery in c.Win32_PortableBattery():
print battery
This code doesn't output anything.
Here's a step-by-step from IDLE:
>>> c = wmi.WMI().Win32_PortableBattery
>>> c
<_wmi_class: \\SONYLAPTOP-01\ROOT\cimv2:Win32_PortableBattery>
>>> c()
[] <----- empty list
I'm testing this on a 2009 Sony Vaio laptop (notebook with a built-in
battery) running Windows 7 Professional (64-bit).
I'm positive I have a battery and that this battery works.
Thanks again for your help on this thread.
Regards,
Malcolm
More information about the python-win32
mailing list