From 0bb0368d076046771eddf21af289beb94fa4672d Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 14 Oct 2015 11:07:31 -0400 Subject: [PATCH] Fix bad or missing noderange behavior in nodelist nodelist command would show 'help' with no arguments, but natural expectation is to list all nodes. Adjust to match that expectation. If a noderange was somehow problematic, the output was not appropriate, this too is addressed. --- confluent_client/bin/nodelist | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/confluent_client/bin/nodelist b/confluent_client/bin/nodelist index a14329c7..9fa5fb3d 100644 --- a/confluent_client/bin/nodelist +++ b/confluent_client/bin/nodelist @@ -34,9 +34,9 @@ argparser.add_option('-b', '--blame', action='store_true', (options, args) = argparser.parse_args() try: noderange = args[0] + nodelist = '/noderange/{0}/nodes/'.format(noderange) except IndexError: - argparser.print_help() - sys.exit(1) + nodelist = '/nodes/' session = client.Command() exitcode = 0 if len(args) > 1: @@ -77,6 +77,10 @@ if len(args) > 1: sys.stderr.write('Error: {0} not a valid attribute\n'.format(attr)) exitcode = 1 else: - for res in session.read('/noderange/{0}/nodes/'.format(noderange)): - print res['item']['href'].replace('/', '') + for res in session.read(nodelist): + if 'error' in res: + sys.stderr.write(res['error'] + '\n') + exitcode = 1 + else: + print res['item']['href'].replace('/', '') sys.exit(exitcode) \ No newline at end of file