From 11138aa3de80569f97e27534bb7fb53f7f07797c Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Sat, 22 Feb 2014 20:22:23 -0500 Subject: [PATCH] Fix confetty interactive behavior after set After set, confetty client would fail to follow protocol and end up leaving followup commands in an off by one state. One TODO out of this is to refactor send_request into a library function --- bin/confetty | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bin/confetty b/bin/confetty index 44ca87ff..e6c8c88e 100755 --- a/bin/confetty +++ b/bin/confetty @@ -149,8 +149,11 @@ def parse_command(command): currchildren = None -def send_request(operation, path, server): - tlvdata.send_tlvdata(server, {'operation': operation, 'path': path}) +def send_request(operation, path, server, parameters=None): + payload = {'operation': operation, 'path': path} + if parameters is not None: + payload['parameters'] = parameters + tlvdata.send_tlvdata(server, payload) result = tlvdata.recv_tlvdata(server) while '_requestdone' not in result: yield result @@ -249,7 +252,12 @@ def setvalues(attribs): value = attrib[attrib.index("=") + 1:] keydata[key] = value targpath = fullpath_target(resource) - tlvdata.send_tlvdata(server, {'operation': 'update', 'path': targpath, 'parameters': keydata}) + for res in send_request('update', targpath, server, keydata): + if 'error' in res: + if 'errorcode' in res: + exitcode = res['errorcode'] + sys.stderr.write('Error: ' + res['error'] + '\n') + return