~ubuntu-branches/ubuntu/karmic/tahoe-lafs/karmic

« back to all changes in this revision

Viewing changes to src/allmydata/scripts/tahoe_rm.py

  • Committer: Bazaar Package Importer
  • Author(s): Zooko O'Whielacronx (Hacker)
  • Date: 2009-09-24 00:00:05 UTC
  • Revision ID: james.westby@ubuntu.com-20090924000005-ixe2n4yngmk49ysz
Tags: upstream-1.5.0
ImportĀ upstreamĀ versionĀ 1.5.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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