<s> from circus . commands . base import Command <EOL> from circus . exc import ArgumentError <EOL> from circus import logger <EOL> class List ( Command ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT:list>" <EOL> def message ( self , * args , ** opts ) : <EOL> if len ( args ) > <NUM_LIT:1> : <EOL> raise ArgumentError ( "<STR_LIT>" ) <EOL> if len ( args ) == <NUM_LIT:1> : <EOL> return self . make_message ( name = args [ <NUM_LIT:0> ] ) <EOL> else : <EOL> return self . make_message ( ) <EOL> def execute ( self , arbiter , props ) : <EOL> if '<STR_LIT:name>' in props : <EOL> watcher = self . _get_watcher ( arbiter , props [ '<STR_LIT:name>' ] ) <EOL> processes = watcher . get_active_processes ( ) <EOL> status = [ ( p . pid , p . status ) for p in processes ] <EOL> logger . debug ( '<STR_LIT>' % status ) <EOL> return { "<STR_LIT>" : [ p . pid for p in processes ] } <EOL> else : <EOL> watchers = sorted ( arbiter . _watchers_names ) <EOL> return { "<STR_LIT>" : [ name for name in watchers ] } <EOL> def console_msg ( self , msg ) : <EOL> if "<STR_LIT>" in msg : <EOL> return "<STR_LIT:U+002C>" . join ( [ str ( process_id ) <EOL> for process_id in msg . get ( '<STR_LIT>' ) ] ) <EOL> elif '<STR_LIT>' in msg : <EOL> return "<STR_LIT:U+002C>" . join ( [ watcher for watcher in msg . get ( '<STR_LIT>' ) ] ) <EOL> if '<STR_LIT>' not in msg : <EOL> msg [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> return self . console_error ( msg ) </s>
