6 from allmydata.scripts.common_http import do_http
8 def mv(nodeurl, dir_uri, frompath, topath, stdout, stderr):
9 frompath = urllib.quote(frompath)
10 topath = urllib.quote(topath)
11 if nodeurl[-1] != "/":
13 url = nodeurl + "uri/%s/" % urllib.quote(dir_uri)
14 data = urllib.urlopen(url + frompath + "?t=json").read()
16 nodetype, attrs = simplejson.loads(data)
17 uri = attrs.get("rw_uri") or attrs["ro_uri"]
18 # simplejson always returns unicode, but we know that it's really just a
22 put_url = url + topath + "?t=uri"
23 resp = do_http("PUT", put_url, uri)
25 if not re.search(r'^2\d\d$', str(status)):
26 print >>stderr, "error, got %s %s" % (resp.status, resp.reason)
27 print >>stderr, resp.read()
29 # now remove the original
30 resp = do_http("DELETE", url + frompath)
31 if not re.search(r'^2\d\d$', str(status)):
32 print >>stderr, "error, got %s %s" % (resp.status, resp.reason)
33 print >>stderr, resp.read()