<s> """<STR_LIT>""" <EOL> from pprint import pprint <EOL> from StringIO import StringIO <EOL> import sys , os <EOL> sys . path . insert ( <NUM_LIT:0> , os . path . join ( os . path . dirname ( __file__ ) , "<STR_LIT:..>" , "<STR_LIT:..>" ) ) <EOL> import urllib2 <EOL> import ssl <EOL> import splunklib . client as client <EOL> try : <EOL> import utils <EOL> except ImportError : <EOL> raise Exception ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> def request ( url , message , ** kwargs ) : <EOL> method = message [ '<STR_LIT>' ] . lower ( ) <EOL> data = message . get ( '<STR_LIT:body>' , "<STR_LIT>" ) if method == '<STR_LIT>' else None <EOL> headers = dict ( message . get ( '<STR_LIT>' , [ ] ) ) <EOL> req = urllib2 . Request ( url , data , headers ) <EOL> try : <EOL> if sys . version_info >= ( <NUM_LIT:2> , <NUM_LIT:7> , <NUM_LIT:9> ) : <EOL> response = urllib2 . urlopen ( req , context = ssl . _create_unverified_context ( ) ) <EOL> else : <EOL> response = urllib2 . urlopen ( req ) <EOL> except urllib2 . HTTPError , response : <EOL> pass <EOL> return { <EOL> '<STR_LIT:status>' : response . code , <EOL> '<STR_LIT>' : response . msg , <EOL> '<STR_LIT>' : response . info ( ) . dict , <EOL> '<STR_LIT:body>' : StringIO ( response . read ( ) ) <EOL> } <EOL> opts = utils . parse ( sys . argv [ <NUM_LIT:1> : ] , { } , "<STR_LIT>" ) <EOL> service = client . connect ( handler = request , ** opts . kwargs ) <EOL> pprint ( [ app . name for app in service . apps ] ) </s>
