~tribaal/txaws/xss-hardening

« back to all changes in this revision

Viewing changes to bin/txaws-delete-object

  • Committer: Duncan McGreggor
  • Date: 2009-11-22 02:20:42 UTC
  • mto: (44.3.2 484858-s3-scripts)
  • mto: This revision was merged to the branch mainline in revision 52.
  • Revision ID: duncan@canonical.com-20091122022042-4zi231hxni1z53xd
* Updated the LICENSE file with copyright information.
* Updated the README with license information.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
"""
3
 
%prog [options]
4
 
"""
5
 
 
6
 
import sys
7
 
 
8
 
from txaws.credentials import AWSCredentials
9
 
from txaws.script import parse_options
10
 
from txaws.service import AWSServiceRegion
11
 
from txaws.reactor import reactor
12
 
 
13
 
 
14
 
def printResults(results):
15
 
    print results
16
 
    return 0
17
 
 
18
 
 
19
 
def printError(error):
20
 
    print error.value
21
 
    return 1
22
 
 
23
 
 
24
 
def finish(return_code):
25
 
    reactor.stop(exitStatus=return_code)
26
 
 
27
 
 
28
 
options, args = parse_options(__doc__.strip())
29
 
if options.bucket is None:
30
 
    print "Error Message: A bucket name is required."
31
 
    sys.exit(1)
32
 
if options.object_name is None:
33
 
    print "Error Message: An object name is required."
34
 
    sys.exit(1)
35
 
creds = AWSCredentials(options.access_key, options.secret_key)
36
 
region = AWSServiceRegion(
37
 
    creds=creds, region=options.region, s3_uri=options.url)
38
 
client = region.get_s3_client()
39
 
 
40
 
d = client.delete_object(options.bucket, options.object_name)
41
 
d.addCallback(printResults)
42
 
d.addErrback(printError)
43
 
d.addCallback(finish)
44
 
# We use a custom reactor so that we can return the exit status from
45
 
# reactor.run().
46
 
sys.exit(reactor.run())