From 35a5e9cbf0cd5928d2063aed9be8b5dbcab9912d Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 23 Oct 2013 13:38:54 -0400 Subject: [PATCH] Continue trying to flesh out socket api --- bin/confetty | 3 +++ confluent/sockapi.py | 10 ++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/bin/confetty b/bin/confetty index ff796ca3..e3936a1b 100755 --- a/bin/confetty +++ b/bin/confetty @@ -136,6 +136,9 @@ elif opts.unixsock: #Next stop, reading and writing from whichever of stdin and server goes first. #see pyghmi code for solconnect.py +banner = server.recv(128) +while "\n" not in banner: + banner += server.recv(128) tty.setraw(sys.stdin.fileno()) fcntl.fcntl(sys.stdin.fileno(), fcntl.F_SETFL, os.O_NONBLOCK) # clear on start can help with readable of TUI, but it diff --git a/confluent/sockapi.py b/confluent/sockapi.py index c6206561..5b3d37c1 100644 --- a/confluent/sockapi.py +++ b/confluent/sockapi.py @@ -24,19 +24,25 @@ def sessionhdl(connection, authname): connection.sendall("Confluent -- v0 --\r\n") if authname is None: # prompt for name and passphrase connection.sendall("Name: ") - username = connection.recv() + username = connection.recv(4096) connection.sendall(username) while "\r" not in username: ddata = connection.recv(4096) + if not ddata: + return connection.sendall(ddata) username += ddata username, _, passphrase = username.partition("\r") connection.sendall("\nPassphrase: ") while "\r" not in passphrase: - passphrase += connection.recv(4096) + pdata = connection.recv(4096) + if not pdata: + return + passphrase += pdata connection.sendall("\r\n") print username print passphrase + connection.sendall("Confluent -- v0 -- Session Granted\r\n/->") cfm = config.ConfigManager(tenant=0) consession = console.ConsoleSession(node='n1', configmanager=cfm, datacallback=connection.sendall)