Trees | Indices | Help |
|
---|
|
A WMI root of a computer system. The classes attribute holds a list of the classes on offer. This means you can explore a bit with things like this: <pre class="code"> c = wmi.WMI () for i in c.classes: if "user" in i.lower (): print i </pre>
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|
Return a list of instances of the WMI class. This is (probably) equivalent to querying with no qualifiers. <pre class="code"> system.instances ("Win32_LogicalDisk") # should be the same as system.Win32_LogicalDisk () </pre> |
Execute a WQL query and return its raw results. Use the flags recommended by Microsoft to achieve a read-only, semi-synchronous query where the time is taken while looping through. Should really be a generator, but ... NB Backslashes need to be doubled up. |
Build and execute a wql query to fetch the specified list of fields from the specified wmi_classname + where_clause, then return the results as a list of simple class instances with attributes matching fields_list. If fields is left empty, select * and pre-load all class attributes for each class returned. |
Set up an event tracker on a WMI event. This function returns an wmi_watcher which can be called to get the next event. eg, <pre class="code"> c = wmi.WMI () raw_wql = "SELECT * FROM __InstanceCreationEvent WITHIN 2 WHERE TargetInstance ISA 'Win32_Process'" watcher = c.watch_for (raw_wql=raw_wql) while 1: process_created = watcher () print process_created.Name # or watcher = c.watch_for ( notification_type="Creation", wmi_class="Win32_Process", delay_secs=2, Name='calc.exe' ) calc_created = watcher () </pre> Now supports timeout on the call to watcher, eg: <pre class="code"> import pythoncom import wmi c = wmi.WMI (privileges=["Security"]) watcher1 = c.watch_for ( notification_type="Creation", wmi_class="Win32_NTLogEvent", Type="error" ) watcher2 = c.watch_for ( notification_type="Creation", wmi_class="Win32_NTLogEvent", Type="warning" ) while 1: try: error_log = watcher1 (500) except wmi.x_wmi_timed_out: pythoncom.PumpWaitingMessages () else: print error_log try: warning_log = watcher2 (500) except wmi.x_wmi_timed_out: pythoncom.PumpWaitingMessages () else: print warning_log </pre> |
Offer WMI classes as simple attributes. Pass through any untrapped unattribute to the underlying OLE object. This means that new or unmapped functionality is still available to the module user. |
Standard caching helper which keeps track of classes already retrieved by name and returns the existing object if found. If this is the first retrieval, store it and pass it back |
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Thu Oct 29 19:07:37 2009 | http://epydoc.sourceforge.net |