#NEWLINE# def select( self , frm , attrs = '*' ) : #NEWLINE# #INDENT# 'Select ``attrs`` from ``frm``\n\n        :rtype: list of dict\n        ' #NEWLINE# enumerator = IEnumWbemClassObject ( ) #NEWLINE# try : #NEWLINE# #INDENT# self . service . ExecQuery ( 'WQL' , 'select * from {0}' . format ( frm ) , 32 , 0 , ctypes . byref ( enumerator ) ) #NEWLINE# #UNINDENT# except WindowsError as e : #NEWLINE# #INDENT# if ( ( e . winerror & 4294967295 ) == WBEM_E_INVALID_CLASS ) : #NEWLINE# #INDENT# raise WindowsError ( e . winerror , 'WBEM_E_INVALID_CLASS <Invalid WMI class "{0}">' . format ( frm ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( e . winerror & 4294967295 ) in WBEMSTATUS . values ) : #NEWLINE# #INDENT# raise WindowsError ( e . winerror , WBEMSTATUS ( ( e . winerror & 4294967295 ) ) . value ) #NEWLINE# #UNINDENT# #UNINDENT# raise #NEWLINE# #UNINDENT# count = ctypes . c_ulong ( 0 ) #NEWLINE# processor = IWbemClassObject ( ) #NEWLINE# res = [ ] #NEWLINE# enumerator . Next ( 4294967295 , 1 , ctypes . byref ( processor ) , ctypes . byref ( count ) ) #NEWLINE# while count . value : #NEWLINE# #INDENT# current_res = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# variant_res = windows . com . ImprovedVariant ( ) #NEWLINE# if ( attrs == '*' ) : #NEWLINE# #INDENT# attrs = [ x for x in self . get_names ( processor ) if ( not x . startswith ( '__' ) ) ] #NEWLINE# #UNINDENT# for name in attrs : #NEWLINE# #INDENT# processor . Get ( name , 0 , ctypes . byref ( variant_res ) , None , None ) #NEWLINE# if ( variant_res . vt & VT_ARRAY ) : #NEWLINE# #INDENT# if ( ( variant_res . vt & VT_TYPEMASK ) == VT_BSTR ) : #NEWLINE# #INDENT# current_res [ name ] = variant_res . asarray . to_list ( BSTR ) #NEWLINE# #UNINDENT# if ( ( variant_res . vt & VT_TYPEMASK ) == VT_I4 ) : #NEWLINE# #INDENT# current_res [ name ] = variant_res . asarray . to_list ( LONG ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( variant_res . vt in [ VT_EMPTY , VT_NULL ] ) : #NEWLINE# #INDENT# current_res [ name ] = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( variant_res . vt == VT_BSTR ) : #NEWLINE# #INDENT# current_res [ name ] = variant_res . asbstr #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( variant_res . vt == VT_I4 ) : #NEWLINE# #INDENT# current_res [ name ] = variant_res . aslong #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( variant_res . vt == VT_BOOL ) : #NEWLINE# #INDENT# current_res [ name ] = variant_res . asbool #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( variant_res . vt == VT_I2 ) : #NEWLINE# #INDENT# current_res [ name ] = variant_res . asshort #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( variant_res . vt == VT_UI1 ) : #NEWLINE# #INDENT# current_res [ name ] = variant_res . asbyte #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# print ( '[WARN] WMI Ignore variant of type {0}' . format ( hex ( variant_res . vt ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# res . append ( current_res ) #NEWLINE# enumerator . Next ( 4294967295 , 1 , ctypes . byref ( processor ) , ctypes . byref ( count ) ) #NEWLINE# #UNINDENT# return res