#NEWLINE# def process( self , args = argv , input_file = stdin , output_file = stdout ) : #NEWLINE# #INDENT# ' Processes search results as specified by command arguments.\n\n        :param args: Sequence of command arguments\n        :param input_file: Pipeline input file\n        :param output_file: Pipeline output file\n\n        ' #NEWLINE# self . logger . debug ( '%s arguments: %s' , type ( self ) . __name__ , args ) #NEWLINE# self . _configuration = None #NEWLINE# self . _output_file = output_file #NEWLINE# try : #NEWLINE# #INDENT# if ( ( len ( args ) >= 2 ) and ( args [ 1 ] == '__GETINFO__' ) ) : #NEWLINE# #INDENT# ( ConfigurationSettings , operation , args , reader ) = self . _prepare ( args , input_file = None ) #NEWLINE# self . parser . parse ( args , self ) #NEWLINE# self . _configuration = ConfigurationSettings ( self ) #NEWLINE# writer = splunk_csv . DictWriter ( output_file , self , self . configuration . keys ( ) , mv_delimiter = ',' ) #NEWLINE# writer . writerow ( self . configuration . items ( ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( len ( args ) >= 2 ) and ( args [ 1 ] == '__EXECUTE__' ) ) : #NEWLINE# #INDENT# self . input_header . read ( input_file ) #NEWLINE# ( ConfigurationSettings , operation , args , reader ) = self . _prepare ( args , input_file ) #NEWLINE# self . parser . parse ( args , self ) #NEWLINE# self . _configuration = ConfigurationSettings ( self ) #NEWLINE# if self . show_configuration : #NEWLINE# #INDENT# self . messages . append ( 'info_message' , ( '%s command configuration settings: %s' % ( self . name , self . _configuration ) ) ) #NEWLINE# #UNINDENT# writer = splunk_csv . DictWriter ( output_file , self ) #NEWLINE# self . _execute ( operation , reader , writer ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# file_name = path . basename ( args [ 0 ] ) #NEWLINE# message = 'Command {0} appears to be statically configured and static configuration is unsupported by splunklib.searchcommands. Please ensure that default/commands.conf contains this stanza:\n[{0}]\nfilename = {1}\nsupports_getinfo = true\nsupports_rawargs = true\noutputheader = true' . format ( type ( self ) . name , file_name ) #NEWLINE# raise NotImplementedError ( message ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# except SystemExit : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# import traceback #NEWLINE# import sys #NEWLINE# ( error_type , error_message , error_traceback ) = sys . exc_info ( ) #NEWLINE# self . logger . error ( traceback . format_exc ( error_traceback ) ) #NEWLINE# origin = error_traceback #NEWLINE# while ( origin . tb_next is not None ) : #NEWLINE# #INDENT# origin = origin . tb_next #NEWLINE# #UNINDENT# filename = origin . tb_frame . f_code . co_filename #NEWLINE# lineno = origin . tb_lineno #NEWLINE# self . write_error ( '%s at "%s", line %d : %s' , error_type . __name__ , filename , lineno , error_message ) #NEWLINE# exit ( 1 ) #NEWLINE# #UNINDENT# return