3 from allmydata.scripts.common_http import do_http, check_http_error
4 from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, UnknownAliasError
5 from allmydata.util.encodingutil import quote_output
8 nodeurl = options['node-url']
9 aliases = options.aliases
11 stdout = options.stdout
12 stderr = options.stderr
13 if not nodeurl.endswith("/"):
17 rootcap, path = get_alias(aliases, where, DEFAULT_ALIAS)
18 except UnknownAliasError, e:
22 if not where or not path:
23 # create a new unlinked directory
24 url = nodeurl + "uri?t=mkdir"
26 url += "&format=%s" % urllib.quote(options['format'])
27 resp = do_http("POST", url)
28 rc = check_http_error(resp, stderr)
31 new_uri = resp.read().strip()
33 print >>stdout, quote_output(new_uri, quotemarks=False)
36 # create a new directory at the given location
37 if path.endswith("/"):
39 # path must be "/".join([s.encode("utf-8") for s in segments])
40 url = nodeurl + "uri/%s/%s?t=mkdir" % (urllib.quote(rootcap),
43 url += "&format=%s" % urllib.quote(options['format'])
45 resp = do_http("POST", url)
46 check_http_error(resp, stderr)
47 new_uri = resp.read().strip()
48 print >>stdout, quote_output(new_uri, quotemarks=False)