Module wmi :: Class _wmi_object
[hide private]
[frames] | no frames]

Class _wmi_object

source code

A lightweight wrapper round an OLE WMI object

Instance Methods [hide private]
 
__init__(self, ole_object, instance_of=None, fields=[], property_map={}) source code
 
__str__(self)
For a call to print [object] return the OLE description of the properties / values of the object
source code
 
__repr__(self)
Indicate both the fact that this is a wrapped WMI object and the WMI object's own identifying class.
source code
 
_cached_properties(self, attribute) source code
 
_cached_methods(self, attribute) source code
 
__getattr__(self, attribute)
Attempt to pass attribute calls to the proxied COM object.
source code
 
__setattr__(self, attribute, value)
If the attribute to be set is valid for the proxied COM object, set that objects's parameter value; if not, raise an exception.
source code
 
__eq__(self, other)
Use WMI's CompareTo_ to compare this object with another.
source code
 
_getAttributeNames(self)
Return list of methods/properties for IPython completion
source code
 
put(self) source code
 
set(self, **kwargs)
Set several properties of the underlying object at one go.
source code
 
path(self)
Return the WMI URI to this object.
source code
 
derivation(self)
Return a tuple representing the object derivation for this object, with the most specific object first.
source code
 
associators(self, wmi_association_class="", wmi_result_class="")
Return a list of objects related to this one, optionally limited either by association class (ie the name of the class which relates them) or by result class (ie the name of the class which would be retrieved)
source code
 
references(self, wmi_class="")
Return a list of associations involving this object, optionally limited by the result class (the name of the association class).
source code
Method Details [hide private]

__getattr__(self, attribute)
(Qualification operator)

source code 

Attempt to pass attribute calls to the proxied COM object. If the attribute is recognised as a property, return its value; if it is recognised as a method, return a method wrapper which can then be called with parameters; otherwise pass the lookup on to the underlying object.

__eq__(self, other)
(Equality operator)

source code 

Use WMI's CompareTo_ to compare this object with another. Don't try to do anything if the other object is not a wmi object. It might be possible to compare this object's unique key with a string or something, but this doesn't seem to be universal enough to merit a special case.

set(self, **kwargs)

source code 

Set several properties of the underlying object at one go. This is particularly useful in combination with the new () method below. However, an instance which has been spawned in this way won't have enough information to write pack, so only try if the instance has a path.

path(self)

source code 

Return the WMI URI to this object. Can be used to determine the path relative to the parent namespace. eg,

<pre class="code"> pp0 = wmi.WMI ().Win32_ParallelPort ()[0] print pp0.path ().RelPath </pre>

derivation(self)

source code 
Return a tuple representing the object derivation for
 this object, with the most specific object first. eg,

pp0 = wmi.WMI ().Win32_ParallelPort ()[0]
print ' <- '.join (pp0.derivation ())

associators(self, wmi_association_class="", wmi_result_class="")

source code 
Return a list of objects related to this one, optionally limited
     either by association class (ie the name of the class which relates
     them) or by result class (ie the name of the class which would be
     retrieved)

    <pre class="code">
c = wmi.WMI ()
pp = c.Win32_ParallelPort ()[0]

for i in pp.associators (wmi_association_class="Win32_PortResource"):
  print i

for i in pp.associators (wmi_result_class="Win32_PnPEntity"):
  print i
    </pre>
    

references(self, wmi_class="")

source code 
Return a list of associations involving this object, optionally
 limited by the result class (the name of the association class).

 NB Associations are treated specially; although WMI only returns
 the string corresponding to the instance of each associated object,
 this module will automatically convert that to the object itself.

<pre class="code">
c =  wmi.WMI ()
sp = c.Win32_SerialPort ()[0]

for i in sp.references ():
  print i

for i in sp.references (wmi_class="Win32_SerialPortSetting"):
  print i
</pre>