mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-25 07:31:07 +00:00
tahoe_ls: improve error message when the target is missing
This commit is contained in:
parent
282e22abcf
commit
15fbe05092
@ -2,6 +2,7 @@
|
|||||||
import urllib, time
|
import urllib, time
|
||||||
import simplejson
|
import simplejson
|
||||||
from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path
|
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):
|
def list(nodeurl, aliases, where, config, stdout, stderr):
|
||||||
if not nodeurl.endswith("/"):
|
if not nodeurl.endswith("/"):
|
||||||
@ -15,7 +16,15 @@ def list(nodeurl, aliases, where, config, stdout, stderr):
|
|||||||
url += "/" + escape_path(path)
|
url += "/" + escape_path(path)
|
||||||
assert not url.endswith("/")
|
assert not url.endswith("/")
|
||||||
url += "?t=json"
|
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']:
|
if config['json']:
|
||||||
print >>stdout, data
|
print >>stdout, data
|
||||||
|
@ -1594,6 +1594,13 @@ class SystemTest(testutil.SignalMixin, testutil.PollMixin, testutil.StallMixin,
|
|||||||
d.addCallback(run, "ls")
|
d.addCallback(run, "ls")
|
||||||
d.addCallback(_check_empty_dir)
|
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 = []
|
files = []
|
||||||
datas = []
|
datas = []
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
|
Loading…
Reference in New Issue
Block a user