<s> import os <EOL> import sys <EOL> from time import strftime , gmtime <EOL> import logging <EOL> import httplib2 <EOL> from datetime import datetime <EOL> import simplejson <EOL> from optparse import OptionParser <EOL> for path in [ <EOL> os . path . join ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> os . path . abspath ( os . path . join ( os . path . dirname ( __file__ ) , '<STR_LIT:..>' , '<STR_LIT>' ) ) <EOL> ] : <EOL> if os . path . exists ( os . path . join ( path , '<STR_LIT>' ) ) : <EOL> sys . path . append ( path ) <EOL> break <EOL> from util import Identity <EOL> import constants <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> parser = OptionParser ( ) <EOL> parser . add_option ( "<STR_LIT>" , "<STR_LIT>" , dest = "<STR_LIT>" , <EOL> help = "<STR_LIT>" , metavar = "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , "<STR_LIT>" , dest = "<STR_LIT>" , default = <NUM_LIT:0> , <EOL> help = "<STR_LIT>" , metavar = "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , "<STR_LIT>" , dest = "<STR_LIT>" , default = <NUM_LIT:0> , <EOL> help = "<STR_LIT>" , metavar = "<STR_LIT>" ) <EOL> ( options , args ) = parser . parse_args ( ) <EOL> if options . identity != None : <EOL> Identity . set_identity ( options . identity ) <EOL> logging . basicConfig ( format = "<STR_LIT>" , datefmt = "<STR_LIT>" , <EOL> level = logging . INFO ) <EOL> logging . info ( "<STR_LIT>" , constants . HTTP_PORT ) <EOL> table = { } <EOL> if int ( options . schema_version ) == <NUM_LIT:0> : <EOL> table = { "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" , "<STR_LIT:int>" , "<STR_LIT:int>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ [ Identity . get_identity ( ) , <NUM_LIT> , <NUM_LIT:5> , "<STR_LIT:yes>" , "<STR_LIT>" ] , <EOL> [ Identity . get_identity ( ) , <NUM_LIT:1000> , <NUM_LIT> , "<STR_LIT>" , strftime ( "<STR_LIT>" , gmtime ( ) ) ] ] <EOL> } <EOL> else : <EOL> table = { "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:foo>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" , "<STR_LIT:int>" , "<STR_LIT:int>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ [ Identity . get_identity ( ) , <NUM_LIT> , <NUM_LIT:5> , "<STR_LIT:yes>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> [ Identity . get_identity ( ) , <NUM_LIT:1000> , <NUM_LIT> , "<STR_LIT>" , strftime ( "<STR_LIT>" , gmtime ( ) ) , "<STR_LIT>" ] ] <EOL> } <EOL> URL = '<STR_LIT>' % ( options . hostname , constants . HTTP_PORT ) <EOL> msg = { "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : Identity . get_identity ( ) , <EOL> "<STR_LIT>" : table <EOL> } <EOL> jsondata = simplejson . dumps ( msg ) <EOL> h = httplib2 . Http ( ) <EOL> resp , content = h . request ( URL , <EOL> '<STR_LIT:POST>' , <EOL> jsondata , <EOL> headers = { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } ) <EOL> print resp <EOL> print content </s>
