source file: /home/buildslave/tahoe/edgy/build/src/allmydata/scripts/tahoe_rm.py
file stats: 25 lines, 20 executed: 80.0% covered
   1. 
   2. import urllib
   3. from allmydata.scripts.common_http import do_http
   4. from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path
   5. 
   6. def rm(options):
   7.     """
   8.     @param verbosity: 0, 1, or 2, meaning quiet, verbose, or very verbose
   9. 
  10.     @return: a Deferred which eventually fires with the exit code
  11.     """
  12.     nodeurl = options['node-url']
  13.     aliases = options.aliases
  14.     where = options.where
  15.     if options['quiet']:
  16.         verbosity = 0
  17.     else:
  18.         verbosity = 2
  19.     stdout = options.stdout
  20.     stderr = options.stderr
  21. 
  22.     if nodeurl[-1] != "/":
  23.         nodeurl += "/"
  24.     rootcap, path = get_alias(aliases, where, DEFAULT_ALIAS)
  25.     assert path
  26.     url = nodeurl + "uri/%s" % urllib.quote(rootcap)
  27.     url += "/" + escape_path(path)
  28. 
  29.     resp = do_http("DELETE", url)
  30. 
  31.     if resp.status in (200,):
  32.         print >>stdout, "%s %s" % (resp.status, resp.reason)
  33.         return 0
  34. 
  35.     print >>stderr, "error, got %s %s" % (resp.status, resp.reason)
  36.     print >>stderr, resp.read()
  37.     return 1