3 from allmydata.scripts.common_http import do_http, check_http_error
4 from allmydata.scripts.common import get_alias, DEFAULT_ALIAS
7 nodeurl = options['node-url']
8 aliases = options.aliases
10 stdout = options.stdout
11 stderr = options.stderr
12 if not nodeurl.endswith("/"):
15 rootcap, path = get_alias(aliases, where, DEFAULT_ALIAS)
17 if not where or not path:
18 # create a new unlinked directory
19 url = nodeurl + "uri?t=mkdir"
20 resp = do_http("POST", url)
21 rc = check_http_error(resp, stderr)
24 new_uri = resp.read().strip()
26 print >>stdout, new_uri
29 # create a new directory at the given location
30 if path.endswith("/"):
32 # path (in argv) must be "/".join([s.encode("utf-8") for s in segments])
33 url = nodeurl + "uri/%s/%s?t=mkdir" % (urllib.quote(rootcap),
35 resp = do_http("POST", url)
36 check_http_error(resp, stderr)
37 new_uri = resp.read().strip()
38 print >>stdout, new_uri