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("/"):
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
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):