From fde68e1320d76091ba2cb00049fafa2896d573ce Mon Sep 17 00:00:00 2001 From: chenglch Date: Tue, 8 Sep 2015 22:52:11 -0400 Subject: [PATCH] Fix 'start console session' command error Command "confetty start /nodes//console/session" can not work correctly. This patch aims to add condition judgement for this command in confetty. --- confluent_client/bin/confetty | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/confluent_client/bin/confetty b/confluent_client/bin/confetty index 8cbdaa29..82019f09 100755 --- a/confluent_client/bin/confetty +++ b/confluent_client/bin/confetty @@ -496,6 +496,18 @@ def quitconfetty(code=0, fullexit=False, fixterm=True): inconsole = False +def get_session_node(shellargs): + # straight to node console + if len(shellargs) == 1 and ' ' not in shellargs[0]: + return shellargs[0] + if len(shellargs) == 2 and shellargs[0] == 'start': + args = [s for s in shellargs[1].split('/') if s] + if len(args) == 4 and args[0] == 'nodes' and args[2] == 'console' and \ + args[3] == 'session': + return args[1] + return None + + def conserver_command(filehandle, command): # x - conserver has that as 'show baud', I am inclined to replace that with # 'request exclusive' @@ -601,16 +613,19 @@ except socket.gaierror: # sys.stdout.flush() if sys.stdout.isatty(): - import readline - readline.parse_and_bind("tab: complete") - readline.parse_and_bind("set bell-style none") - readline.set_completer(completer) + import readline + + readline.parse_and_bind("tab: complete") + readline.parse_and_bind("set bell-style none") + readline.set_completer(completer) + doexit = False inconsole = False pendingcommand = "" -if len(shellargs) == 1 and ' ' not in shellargs[0]: # straight to node console +session_node = get_session_node(shellargs) +if session_node is not None: consoleonly = True - do_command("start /nodes/%s/console/session" % shellargs[0], netserver) + do_command("start /nodes/%s/console/session" % session_node, netserver) doexit = True elif shellargs: command = " ".join(shellargs)