<s> import sys <EOL> from twisted . internet import reactor , defer <EOL> from txtorcon import TorInfo , build_local_tor_connection <EOL> def error ( x ) : <EOL> print "<STR_LIT>" , x <EOL> return x <EOL> @ defer . inlineCallbacks <EOL> def recursive_dump ( indent , obj , depth = <NUM_LIT:0> ) : <EOL> if callable ( obj ) : <EOL> try : <EOL> print "<STR_LIT>" % obj , <EOL> sys . stdout . flush ( ) <EOL> if obj . takes_arg : <EOL> v = yield obj ( '<STR_LIT>' ) <EOL> v = yield obj ( ) <EOL> v = v . replace ( '<STR_LIT:\n>' , '<STR_LIT:\\>' ) <EOL> if len ( v ) > <NUM_LIT> : <EOL> v = v [ : <NUM_LIT:50> ] + '<STR_LIT>' + v [ - <NUM_LIT:7> : ] <EOL> except Exception , e : <EOL> v = '<STR_LIT>' + str ( e ) <EOL> print v <EOL> else : <EOL> indent = indent + '<STR_LIT:U+0020>' <EOL> for x in obj : <EOL> yield recursive_dump ( indent , x , depth + <NUM_LIT:1> ) <EOL> @ defer . inlineCallbacks <EOL> def setup_complete ( info ) : <EOL> print "<STR_LIT>" , dir ( info ) <EOL> if True : <EOL> v = yield info . version ( ) <EOL> ip = yield info . ip_to_country ( '<STR_LIT>' ) <EOL> boot_phase = yield info . status . bootstrap_phase ( ) <EOL> ns = yield info . ns . name ( '<STR_LIT>' ) <EOL> guards = yield info . entry_guards ( ) <EOL> print '<STR_LIT>' , v <EOL> print '<STR_LIT>' , ip <EOL> print '<STR_LIT>' , boot_phase <EOL> print '<STR_LIT>' , ns <EOL> print '<STR_LIT>' , guards <EOL> d = recursive_dump ( '<STR_LIT>' , info ) <EOL> d . addCallback ( lambda x : reactor . stop ( ) ) <EOL> d . addErrback ( error ) <EOL> def setup_failed ( arg ) : <EOL> print "<STR_LIT>" , arg <EOL> reactor . stop ( ) <EOL> def bootstrap ( c ) : <EOL> info = TorInfo ( c ) <EOL> info . post_bootstrap . addCallback ( setup_complete ) . addErrback ( setup_failed ) <EOL> d = build_local_tor_connection ( reactor , build_state = False ) <EOL> d . addCallback ( bootstrap ) . addErrback ( setup_failed ) <EOL> reactor . run ( ) </s>
