3 from allmydata.scripts.common_http import do_http, format_http_success, format_http_error
4 from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path, \
7 def unlink(options, command="unlink"):
9 @return: a Deferred which eventually fires with the exit code
11 nodeurl = options['node-url']
12 aliases = options.aliases
14 stdout = options.stdout
15 stderr = options.stderr
17 if nodeurl[-1] != "/":
20 rootcap, path = get_alias(aliases, where, DEFAULT_ALIAS)
21 except UnknownAliasError, e:
26 'tahoe %s' can only unlink directory entries, so a path must be given.""" % (command,)
29 url = nodeurl + "uri/%s" % urllib.quote(rootcap)
30 url += "/" + escape_path(path)
32 resp = do_http("DELETE", url)
34 if resp.status in (200,):
35 print >>stdout, format_http_success(resp)
38 print >>stderr, format_http_error("ERROR", resp)