<s> import copy <EOL> from ... console_output import colored , GAFFER_COLORS <EOL> from ... httpclient import GafferNotFound <EOL> from ... lookupd . client import LookupServer <EOL> from ... util import is_ssl <EOL> from . base import Command <EOL> import pyuv <EOL> class LookupNodes ( Command ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> short_descr = "<STR_LIT>" <EOL> def run ( self , config , args ) : <EOL> lookupd_addresses = set ( args [ '<STR_LIT>' ] ) <EOL> loop = pyuv . Loop . default_loop ( ) <EOL> all_nodes = [ ] <EOL> for addr in lookupd_addresses : <EOL> s = LookupServer ( addr , loop = loop , ** config . client_options ) <EOL> resp = s . nodes ( ) <EOL> for node in resp [ '<STR_LIT>' ] : <EOL> if node not in all_nodes : <EOL> all_nodes . append ( node ) <EOL> print ( "<STR_LIT>" % len ( all_nodes ) ) <EOL> balance = copy . copy ( GAFFER_COLORS ) <EOL> for node in all_nodes : <EOL> line = "<STR_LIT>" % ( node [ '<STR_LIT>' ] , node [ '<STR_LIT:name>' ] , <EOL> node [ '<STR_LIT:version>' ] ) <EOL> color , balance = self . get_color ( balance ) <EOL> print ( colored ( color , line ) ) <EOL> def get_color ( self , balance ) : <EOL> code = balance . pop ( <NUM_LIT:0> ) <EOL> balance . append ( code ) <EOL> return code , balance </s>
