<s> from circus . commands . base import Command <EOL> import operator <EOL> class ListSockets ( Command ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> def message ( self , * args , ** opts ) : <EOL> return self . make_message ( ) <EOL> def execute ( self , arbiter , props ) : <EOL> def _get_info ( socket ) : <EOL> sock = { '<STR_LIT>' : socket . fileno ( ) , <EOL> '<STR_LIT:name>' : socket . name , <EOL> '<STR_LIT>' : socket . backlog } <EOL> if socket . host is not None : <EOL> sock [ '<STR_LIT:host>' ] = socket . host <EOL> sock [ '<STR_LIT:port>' ] = socket . port <EOL> else : <EOL> sock [ '<STR_LIT:path>' ] = socket . path <EOL> return sock <EOL> sockets = [ _get_info ( socket ) for socket in arbiter . sockets . values ( ) ] <EOL> sockets . sort ( key = operator . itemgetter ( '<STR_LIT>' ) ) <EOL> return { "<STR_LIT>" : sockets } <EOL> def console_msg ( self , msg ) : <EOL> if '<STR_LIT>' in msg : <EOL> sockets = [ ] <EOL> for sock in msg [ '<STR_LIT>' ] : <EOL> d = "<STR_LIT>" <EOL> if '<STR_LIT:path>' in sock : <EOL> d = ( d + '<STR_LIT>' ) % sock <EOL> else : <EOL> d = ( d + '<STR_LIT>' ) % sock <EOL> sockets . append ( d ) <EOL> return "<STR_LIT:\n>" . join ( sockets ) <EOL> return self . console_error ( msg ) </s>
