<s> __author__ = '<STR_LIT>' <EOL> import argparse <EOL> import msgpack <EOL> import os <EOL> from interface . services . icontainer_agent import IContainerAgent , ContainerAgentClient <EOL> from pyon . net . messaging import make_node <EOL> from pyon . core . bootstrap import CFG , bootstrap_pyon <EOL> def main ( ) : <EOL> parser = argparse . ArgumentParser ( description = "<STR_LIT>" ) <EOL> parser . add_argument ( "<STR_LIT>" , help = "<STR_LIT>" ) <EOL> parser . add_argument ( "<STR_LIT>" , help = "<STR_LIT>" , choices = IContainerAgent . names ( ) ) <EOL> parser . add_argument ( "<STR_LIT>" , metavar = "<STR_LIT>" , nargs = "<STR_LIT:*>" , help = "<STR_LIT>" ) <EOL> opts = parser . parse_args ( ) <EOL> pidfile = opts . pidfile <EOL> if not pidfile : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> parms = { } <EOL> with open ( pidfile , '<STR_LIT:r>' ) as pf : <EOL> parms = msgpack . loads ( pf . read ( ) ) <EOL> assert parms , "<STR_LIT>" <EOL> bootstrap_pyon ( ) <EOL> node , ioloop = make_node ( parms [ '<STR_LIT>' ] ) <EOL> node . setup_interceptors ( CFG . interceptor ) <EOL> cc = ContainerAgentClient ( node = node , to_name = ( parms [ '<STR_LIT>' ] , parms [ '<STR_LIT>' ] ) ) <EOL> methdefs = [ x [ <NUM_LIT:1> ] for x in IContainerAgent . namesAndDescriptions ( ) if x [ <NUM_LIT:0> ] == opts . command ] <EOL> assert len ( methdefs ) == <NUM_LIT:1> <EOL> arg_names = methdefs [ <NUM_LIT:0> ] . positional <EOL> msg_args = dict ( zip ( arg_names , opts . commandargs ) ) <EOL> retval = cc . request ( msg_args , op = opts . command ) <EOL> if opts . command == "<STR_LIT:status>" : <EOL> statstr = retval <EOL> print "<STR_LIT>" , statstr <EOL> if statstr != "<STR_LIT>" : <EOL> node . client . close ( ) <EOL> sys . exit ( <NUM_LIT:2> ) <EOL> else : <EOL> print "<STR_LIT>" , retval <EOL> node . client . close ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
