import stem.descriptor.remote #try: # for desc in stem.descriptor.remote.get_consensus(): # print("found relay %s (%s)" % (desc.nickname, desc.fingerprint)) #except Exception as exc: # print("Unable to retrieve the consensus: %s" % exc endpoint = ('127.0.0.1', 8080) try: consensus = stem.descriptor.remote.get_consensus( endpoints = (stem.DirPort('127.0.0.1', 7000),) ) print('got consensus: {}'.format(consensus)) for desc in consensus: print("found relay %s (%s) - %s" % (desc.nickname, desc.fingerprint, desc.exit_policy)) for x in [desc for desc in consensus if desc.exit_policy.can_exit_to(*endpoint)]: print('%s' % (x.nickname)) except Exception as exc: print("Unable to retrieve the consensus: %s" % exc)