<s> import json <EOL> from distutils . spawn import find_executable <EOL> import wmi_client_wrapper as wmi <EOL> from st2actions . runners . pythonrunner import Action <EOL> __all__ = [ <EOL> '<STR_LIT>' <EOL> ] <EOL> WMIC_EXISTS = find_executable ( '<STR_LIT>' ) is not None <EOL> class WMIQueryAction ( Action ) : <EOL> def run ( self , host , password , query , username = '<STR_LIT>' ) : <EOL> if not WMIC_EXISTS : <EOL> msg = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> raise Exception ( msg ) <EOL> client = self . _get_client ( host = host , username = username , <EOL> password = password ) <EOL> result = client . query ( query ) <EOL> try : <EOL> result = json . dumps ( result ) <EOL> except Exception : <EOL> pass <EOL> return result <EOL> def _get_client ( self , host , username , password ) : <EOL> client = wmi . WmiClientWrapper ( username = username , <EOL> password = password , <EOL> host = host ) <EOL> return client </s>
