@@ -1282,56 +1282,55 @@ def help_version(self):
12821282 "version\t \t \t Show the version of the remote supervisord "
12831283 "process" )
12841284
1285- def do_fg (self , args = None ):
1285+ def do_fg (self , arg ):
12861286 if not self .ctl .upcheck ():
12871287 return
12881288
1289- if not args :
1290- self .handle_error ('Error: no process name supplied' )
1289+ names = arg .split ()
1290+ if not names :
1291+ self .handle_error ('ERROR: no process name supplied' )
12911292 self .help_fg ()
12921293 return
1293-
1294- args = args .split ()
1295- if len (args ) > 1 :
1296- self .handle_error ('Error: too many process names supplied' )
1294+ if len (names ) > 1 :
1295+ self .handle_error ('ERROR: too many process names supplied' )
12971296 return
12981297
1299- program = args [0 ]
1298+ name = names [0 ]
13001299 supervisor = self .ctl .get_supervisor ()
1300+
13011301 try :
1302- info = supervisor .getProcessInfo (program )
1303- except xmlrpclib .Fault as msg :
1304- if msg .faultCode == xmlrpc .Faults .BAD_NAME :
1305- self .handle_error ('Error: bad process name supplied' )
1306- return
1307- # for any other fault
1308- self .ctl .output (str (msg ))
1302+ info = supervisor .getProcessInfo (name )
1303+ except xmlrpclib .Fault as e :
1304+ if e .faultCode == xmlrpc .Faults .BAD_NAME :
1305+ self .handle_error ('ERROR: bad process name supplied' )
1306+ else :
1307+ self .ctl .output ('ERROR: ' + str (e ))
13091308 return
13101309
1311- if not info ['state' ] = = states .ProcessStates .RUNNING :
1312- self .handle_error ('Error : process not running' )
1310+ if info ['state' ] ! = states .ProcessStates .RUNNING :
1311+ self .handle_error ('ERROR : process not running' )
13131312 return
13141313
13151314 a = None
13161315 try :
13171316 # this thread takes care of the output/error messages
1318- a = fgthread (program , self .ctl )
1317+ a = fgthread (name , self .ctl )
13191318 a .start ()
13201319
13211320 # this takes care of the user input
13221321 while True :
13231322 inp = raw_input () + '\n '
13241323 try :
1325- supervisor .sendProcessStdin (program , inp )
1326- except xmlrpclib .Fault as msg :
1327- if msg .faultCode == xmlrpc .Faults .NOT_RUNNING :
1324+ supervisor .sendProcessStdin (name , inp )
1325+ except xmlrpclib .Fault as e :
1326+ if e .faultCode == xmlrpc .Faults .NOT_RUNNING :
13281327 self .ctl .output ('Process got killed' )
13291328 self .ctl .output ('Exiting foreground' )
13301329 a .kill ()
13311330 return
13321331
1333- info = supervisor .getProcessInfo (program )
1334- if not info ['state' ] = = states .ProcessStates .RUNNING :
1332+ info = supervisor .getProcessInfo (name )
1333+ if info ['state' ] ! = states .ProcessStates .RUNNING :
13351334 self .ctl .output ('Process got killed' )
13361335 self .ctl .output ('Exiting foreground' )
13371336 a .kill ()
0 commit comments