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

Class _wmi_class

source code


Currying class to assist in issuing queries against
 a WMI namespace. The idea is that when someone issues
 an otherwise unknown method against the WMI object, if
 it matches a known WMI class a query object will be
 returned which may then be called with one or more params
 which will form the WHERE clause. eg,

<pre class="code">
c = wmi.WMI ()
c_drive = c.Win32_LogicalDisk (Name='C:')
</pre>

Instance Methods [hide private]
 
__init__(self, namespace, wmi_class) source code
 
query(self, fields=[], **where_clause)
Make it slightly easier to query against the class, by calling the namespace's query with the class preset.
source code
 
__call__(self, fields=[], **where_clause)
Make it slightly easier to query against the class, by calling the namespace's query with the class preset.
source code
 
watch_for(self, notification_type="operation", delay_secs=1, **where_clause) source code
 
instances(self)
Return a list of instances of the WMI class
source code
 
new(self, **kwargs)
This is the equivalent to the raw-WMI SpawnInstance_ method.
source code
 
__eq__(self, other)
Use WMI's CompareTo_ to compare this object with another. (Inherited from wmi._wmi_object)
source code
 
__getattr__(self, attribute)
Attempt to pass attribute calls to the proxied COM object. (Inherited from wmi._wmi_object)
source code
 
__repr__(self)
Indicate both the fact that this is a wrapped WMI object and the WMI object's own identifying class. (Inherited from wmi._wmi_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. (Inherited from wmi._wmi_object)
source code
 
__str__(self)
For a call to print [object] return the OLE description of the properties / values of the object (Inherited from wmi._wmi_object)
source code
 
_cached_methods(self, attribute) (Inherited from wmi._wmi_object) source code
 
_cached_properties(self, attribute) (Inherited from wmi._wmi_object) source code
 
_getAttributeNames(self)
Return list of methods/properties for IPython completion (Inherited from wmi._wmi_object)
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) (Inherited from wmi._wmi_object)
source code
 
derivation(self)
Return a tuple representing the object derivation for this object, with the most specific object first. (Inherited from wmi._wmi_object)
source code
 
path(self)
Return the WMI URI to this object. (Inherited from wmi._wmi_object)
source code
 
put(self) (Inherited from wmi._wmi_object) 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). (Inherited from wmi._wmi_object)
source code
 
set(self, **kwargs)
Set several properties of the underlying object at one go. (Inherited from wmi._wmi_object)
source code
Method Details [hide private]

__init__(self, namespace, wmi_class)
(Constructor)

source code 
Overrides: _wmi_object.__init__

query(self, fields=[], **where_clause)

source code 

Make it slightly easier to query against the class, by calling the namespace's query with the class preset. Won't work if the class has been instantiated directly.

__call__(self, fields=[], **where_clause)
(Call operator)

source code 

Make it slightly easier to query against the class, by calling the namespace's query with the class preset. Won't work if the class has been instantiated directly.

new(self, **kwargs)

source code 
This is the equivalent to the raw-WMI SpawnInstance_
 method. Note that there are relatively few uses for
 this, certainly fewer than you might imagine. Most
 classes which need to create a new *real* instance
 of themselves, eg Win32_Process, offer a .Create
 method. SpawnInstance_ is generally reserved for
 instances which are passed as parameters to such
 .Create methods, a common example being the
 Win32_SecurityDescriptor, passed to Win32_Share.Create
 and other instances which need security.

The example here is Win32_ProcessStartup, which
controls the shown/hidden state etc. of a new
Win32_Process instance.

<pre class="code">
import win32con
import wmi
c = wmi.WMI ()
startup = c.Win32_ProcessStartup.new (ShowWindow=win32con.SW_SHOWMINIMIZED)
pid, retval = c.Win32_Process.Create (
  CommandLine="notepad.exe",
  ProcessStartupInformation=startup
)
</pre>

NB previous versions of this module, used this function
to create new process. This is *not* a good example
of its use; it is better handled with something like
the example above.