From c79230c854fd8369187da1ea280fae78fb3ef2e8 Mon Sep 17 00:00:00 2001 From: Zooko O'Whielacronx Date: Sat, 20 Dec 2008 07:49:18 -0700 Subject: [PATCH] cli: if response code from wapi server is not 200 then stop instead of proceeding Also, include the data that failed to json parse in an exception raised by the json parser. --- src/allmydata/scripts/tahoe_ls.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/allmydata/scripts/tahoe_ls.py b/src/allmydata/scripts/tahoe_ls.py index d0d63799..88e09a47 100644 --- a/src/allmydata/scripts/tahoe_ls.py +++ b/src/allmydata/scripts/tahoe_ls.py @@ -30,13 +30,22 @@ def list(options): print >>stderr, "Error during GET: %s %s %s" % (resp.status, resp.reason, resp.read()) + if resp.status == 0: + return 3 + else: + return resp.status + data = resp.read() if options['json']: print >>stdout, data return - parsed = simplejson.loads(data) + try: + parsed = simplejson.loads(data) + except Exception, le: + le.args = tuple(le.args + (data,)) + raise nodetype, d = parsed children = {} if nodetype == "dirnode": -- 2.45.2