<s> """<STR_LIT>""" <EOL> import sys , os <EOL> sys . path . insert ( <NUM_LIT:0> , os . path . join ( os . path . dirname ( __file__ ) , "<STR_LIT:..>" , "<STR_LIT:..>" ) ) <EOL> import urllib <EOL> import splunklib . binding as binding <EOL> try : <EOL> import utils <EOL> except ImportError : <EOL> raise Exception ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> RULES = { <EOL> "<STR_LIT:name>" : { <EOL> '<STR_LIT>' : [ "<STR_LIT>" ] , <EOL> '<STR_LIT>' : "<STR_LIT>" <EOL> } , <EOL> "<STR_LIT>" : { <EOL> '<STR_LIT>' : [ "<STR_LIT>" ] , <EOL> '<STR_LIT>' : "<STR_LIT>" <EOL> } , <EOL> "<STR_LIT>" : { <EOL> '<STR_LIT>' : [ "<STR_LIT>" ] , <EOL> '<STR_LIT>' : "<STR_LIT>" <EOL> } , <EOL> "<STR_LIT>" : { <EOL> '<STR_LIT>' : [ "<STR_LIT>" ] , <EOL> '<STR_LIT>' : "<STR_LIT>" <EOL> } , <EOL> "<STR_LIT>" : { <EOL> '<STR_LIT>' : [ "<STR_LIT>" ] , <EOL> '<STR_LIT>' : "<STR_LIT>" <EOL> } , <EOL> "<STR_LIT>" : { <EOL> '<STR_LIT>' : [ "<STR_LIT>" ] , <EOL> '<STR_LIT>' : "<STR_LIT>" <EOL> } , <EOL> "<STR_LIT>" : { <EOL> '<STR_LIT>' : [ "<STR_LIT>" ] , <EOL> '<STR_LIT>' : "<STR_LIT>" <EOL> } , <EOL> "<STR_LIT>" : { <EOL> '<STR_LIT>' : [ "<STR_LIT>" ] , <EOL> '<STR_LIT>' : "<STR_LIT>" <EOL> } , <EOL> "<STR_LIT>" : { <EOL> '<STR_LIT>' : [ "<STR_LIT>" ] , <EOL> '<STR_LIT>' : "<STR_LIT>" <EOL> } , <EOL> "<STR_LIT>" : { <EOL> '<STR_LIT>' : [ "<STR_LIT>" ] , <EOL> '<STR_LIT>' : "<STR_LIT>" <EOL> } , <EOL> "<STR_LIT>" : { <EOL> '<STR_LIT>' : [ "<STR_LIT>" ] , <EOL> '<STR_LIT>' : "<STR_LIT>" <EOL> } , <EOL> "<STR_LIT>" : { <EOL> '<STR_LIT>' : [ "<STR_LIT>" ] , <EOL> '<STR_LIT>' : "<STR_LIT>" <EOL> } , <EOL> "<STR_LIT>" : { <EOL> '<STR_LIT>' : [ "<STR_LIT>" ] , <EOL> '<STR_LIT>' : "<STR_LIT>" <EOL> } , <EOL> "<STR_LIT>" : { <EOL> '<STR_LIT>' : [ "<STR_LIT>" ] , <EOL> '<STR_LIT>' : "<STR_LIT>" <EOL> } , <EOL> "<STR_LIT>" : { <EOL> '<STR_LIT>' : [ "<STR_LIT>" ] , <EOL> '<STR_LIT>' : "<STR_LIT>" <EOL> } , <EOL> "<STR_LIT>" : { <EOL> '<STR_LIT>' : [ "<STR_LIT>" ] , <EOL> '<STR_LIT>' : "<STR_LIT>" <EOL> } , <EOL> "<STR_LIT>" : { <EOL> '<STR_LIT>' : [ "<STR_LIT>" ] , <EOL> '<STR_LIT>' : "<STR_LIT>" <EOL> } , <EOL> "<STR_LIT>" : { <EOL> '<STR_LIT>' : [ "<STR_LIT>" ] , <EOL> '<STR_LIT>' : "<STR_LIT>" <EOL> } , <EOL> "<STR_LIT>" : { <EOL> '<STR_LIT>' : [ "<STR_LIT>" ] , <EOL> '<STR_LIT>' : "<STR_LIT>" <EOL> } , <EOL> "<STR_LIT>" : { <EOL> '<STR_LIT>' : [ "<STR_LIT>" ] , <EOL> '<STR_LIT>' : "<STR_LIT>" <EOL> } , <EOL> "<STR_LIT>" : { <EOL> '<STR_LIT>' : [ "<STR_LIT>" ] , <EOL> '<STR_LIT>' : "<STR_LIT>" <EOL> } , <EOL> "<STR_LIT>" : { <EOL> '<STR_LIT>' : [ "<STR_LIT>" ] , <EOL> '<STR_LIT>' : "<STR_LIT>" <EOL> } , <EOL> "<STR_LIT>" : { <EOL> '<STR_LIT>' : [ "<STR_LIT>" ] , <EOL> '<STR_LIT>' : "<STR_LIT>" <EOL> } , <EOL> "<STR_LIT>" : { <EOL> '<STR_LIT>' : [ "<STR_LIT>" ] , <EOL> '<STR_LIT>' : "<STR_LIT>" <EOL> } , <EOL> "<STR_LIT>" : { <EOL> '<STR_LIT>' : [ "<STR_LIT>" ] , <EOL> '<STR_LIT>' : "<STR_LIT>" <EOL> } , <EOL> "<STR_LIT>" : { <EOL> '<STR_LIT>' : [ "<STR_LIT>" ] , <EOL> '<STR_LIT>' : "<STR_LIT>" <EOL> } , <EOL> "<STR_LIT>" : { <EOL> '<STR_LIT>' : [ "<STR_LIT>" ] , <EOL> '<STR_LIT>' : "<STR_LIT>" <EOL> } , <EOL> "<STR_LIT>" : { <EOL> '<STR_LIT>' : [ "<STR_LIT>" ] , <EOL> '<STR_LIT>' : "<STR_LIT>" <EOL> } , <EOL> "<STR_LIT>" : { <EOL> '<STR_LIT>' : [ "<STR_LIT>" ] , <EOL> '<STR_LIT>' : "<STR_LIT>" <EOL> } , <EOL> "<STR_LIT>" : { <EOL> '<STR_LIT>' : [ "<STR_LIT>" ] , <EOL> '<STR_LIT>' : "<STR_LIT>" <EOL> } <EOL> } <EOL> def main ( argv ) : <EOL> """<STR_LIT>""" <EOL> usage = '<STR_LIT>' <EOL> opts = utils . parse ( argv , RULES , "<STR_LIT>" , usage = usage ) <EOL> context = binding . connect ( ** opts . kwargs ) <EOL> operation = None <EOL> kwargs = { } <EOL> for key in RULES . keys ( ) : <EOL> if opts . kwargs . has_key ( key ) : <EOL> if key == "<STR_LIT>" : <EOL> operation = opts . kwargs [ key ] <EOL> else : <EOL> kwargs [ key ] = opts . kwargs [ key ] <EOL> if not operation : <EOL> if kwargs . has_key ( '<STR_LIT:name>' ) : <EOL> operation = '<STR_LIT:list>' <EOL> else : <EOL> operation = '<STR_LIT>' <EOL> if ( operation != "<STR_LIT:list>" and operation != "<STR_LIT>" <EOL> and operation != "<STR_LIT>" <EOL> and operation != "<STR_LIT>" ) : <EOL> print "<STR_LIT>" % operation <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> if not kwargs . has_key ( '<STR_LIT:name>' ) and operation != "<STR_LIT>" : <EOL> print "<STR_LIT>" <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> if operation != "<STR_LIT>" and operation != "<STR_LIT>" : <EOL> name = kwargs [ '<STR_LIT:name>' ] <EOL> kwargs . pop ( '<STR_LIT:name>' ) <EOL> if operation == "<STR_LIT>" : <EOL> result = context . get ( "<STR_LIT>" , ** kwargs ) <EOL> elif operation == "<STR_LIT:list>" : <EOL> result = context . get ( "<STR_LIT>" % name , ** kwargs ) <EOL> elif operation == "<STR_LIT>" : <EOL> result = context . post ( "<STR_LIT>" , ** kwargs ) <EOL> else : <EOL> result = context . delete ( "<STR_LIT>" % name , ** kwargs ) <EOL> print "<STR_LIT>" % result . status <EOL> xml_data = result . body . read ( ) <EOL> sys . stdout . write ( xml_data ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> main ( sys . argv [ <NUM_LIT:1> : ] ) </s>
