From: Brian Warner Date: Thu, 22 May 2008 00:34:52 +0000 (-0700) Subject: tahoe_ls: improve error message when the target is missing X-Git-Tag: allmydata-tahoe-1.1.0~85 X-Git-Url: https://git.rkrishnan.org/pf/content/frontends/statistics?a=commitdiff_plain;h=15fbe050924515c7c6332091ba0c63a0467e916c;p=tahoe-lafs%2Ftahoe-lafs.git tahoe_ls: improve error message when the target is missing --- diff --git a/src/allmydata/scripts/tahoe_ls.py b/src/allmydata/scripts/tahoe_ls.py index 13eda5ae..731cc527 100644 --- a/src/allmydata/scripts/tahoe_ls.py +++ b/src/allmydata/scripts/tahoe_ls.py @@ -2,6 +2,7 @@ import urllib, time import simplejson from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path +from allmydata.scripts.common_http import do_http def list(nodeurl, aliases, where, config, stdout, stderr): if not nodeurl.endswith("/"): @@ -15,7 +16,15 @@ def list(nodeurl, aliases, where, config, stdout, stderr): url += "/" + escape_path(path) assert not url.endswith("/") url += "?t=json" - data = urllib.urlopen(url).read() + resp = do_http("GET", url) + if resp.status == 404: + print >>stderr, "No such file or directory" + return 2 + if resp.status != 200: + print >>stderr, "Error during GET: %s %s %s" % (resp.status, + resp.reason, + resp.read()) + data = resp.read() if config['json']: print >>stdout, data diff --git a/src/allmydata/test/test_system.py b/src/allmydata/test/test_system.py index 390e84d2..621c2c31 100644 --- a/src/allmydata/test/test_system.py +++ b/src/allmydata/test/test_system.py @@ -1594,6 +1594,13 @@ class SystemTest(testutil.SignalMixin, testutil.PollMixin, testutil.StallMixin, d.addCallback(run, "ls") d.addCallback(_check_empty_dir) + def _check_missing_dir((out,err)): + # TODO: check that rc==2 + self.failUnlessEqual(out, "") + self.failUnlessEqual(err, "No such file or directory\n") + d.addCallback(run, "ls", "bogus") + d.addCallback(_check_missing_dir) + files = [] datas = [] for i in range(10):