<s> from __future__ import print_function <EOL> import aerospike <EOL> import sys <EOL> from optparse import OptionParser <EOL> usage = "<STR_LIT>" <EOL> optparser = OptionParser ( usage = usage , add_help_option = False ) <EOL> optparser . add_option ( <EOL> "<STR_LIT>" , "<STR_LIT>" , dest = "<STR_LIT:host>" , type = "<STR_LIT:string>" , default = "<STR_LIT:127.0.0.1>" , metavar = "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> optparser . add_option ( <EOL> "<STR_LIT>" , "<STR_LIT>" , dest = "<STR_LIT:username>" , type = "<STR_LIT:string>" , metavar = "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> optparser . add_option ( <EOL> "<STR_LIT>" , "<STR_LIT>" , dest = "<STR_LIT:password>" , type = "<STR_LIT:string>" , metavar = "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> optparser . add_option ( <EOL> "<STR_LIT>" , "<STR_LIT>" , dest = "<STR_LIT:port>" , type = "<STR_LIT:int>" , default = <NUM_LIT> , metavar = "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> optparser . add_option ( <EOL> "<STR_LIT>" , dest = "<STR_LIT>" , action = "<STR_LIT:store_true>" , <EOL> help = "<STR_LIT>" ) <EOL> optparser . add_option ( <EOL> "<STR_LIT>" , "<STR_LIT>" , dest = "<STR_LIT>" , type = "<STR_LIT:string>" , default = "<STR_LIT:test>" , metavar = "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> optparser . add_option ( <EOL> "<STR_LIT>" , "<STR_LIT>" , dest = "<STR_LIT>" , type = "<STR_LIT:string>" , default = "<STR_LIT>" , metavar = "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> optparser . add_option ( <EOL> "<STR_LIT>" , "<STR_LIT>" , dest = "<STR_LIT>" , type = "<STR_LIT:string>" , action = "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> ( options , args ) = optparser . parse_args ( ) <EOL> if options . help : <EOL> optparser . print_help ( ) <EOL> print ( ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> config = { <EOL> '<STR_LIT>' : [ ( options . host , options . port ) ] <EOL> } <EOL> exitCode = <NUM_LIT:0> <EOL> try : <EOL> client = aerospike . client ( config ) . connect ( <EOL> options . username , options . password ) <EOL> try : <EOL> namespace = options . namespace if options . namespace and options . namespace != '<STR_LIT:None>' else None <EOL> set = options . set if options . set and options . set != '<STR_LIT:None>' else None <EOL> s = client . scan ( namespace , set ) <EOL> if options . bins and len ( options . bins ) > <NUM_LIT:0> : <EOL> s . select ( * options . bins ) <EOL> records = [ ] <EOL> def callback ( input_tuple ) : <EOL> ( _ , _ , record ) = input_tuple <EOL> records . append ( record ) <EOL> print ( record ) <EOL> s . foreach ( callback ) <EOL> print ( "<STR_LIT>" ) <EOL> if len ( records ) == <NUM_LIT:1> : <EOL> print ( "<STR_LIT>" ) <EOL> else : <EOL> print ( "<STR_LIT>" % len ( records ) ) <EOL> except Exception as e : <EOL> print ( "<STR_LIT>" . format ( e ) , file = sys . stderr ) <EOL> rc = <NUM_LIT:1> <EOL> client . close ( ) <EOL> except Exception as eargs : <EOL> print ( "<STR_LIT>" . format ( eargs ) , file = sys . stderr ) <EOL> exitCode = <NUM_LIT:3> <EOL> sys . exit ( exitCode ) </s>
