/usr/bin/txaws-list-buckets is in python-txaws 0.2-0ubuntu10.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | #!/usr/bin/python
"""
%prog [options]
"""
import sys
from txaws.credentials import AWSCredentials
from txaws.script import parse_options
from txaws.service import AWSServiceRegion
from txaws.reactor import reactor
def printResults(results):
print "\nBuckets:"
for bucket in results:
print "\t%s (created on %s)" % (bucket.name, bucket.creation_date)
print "Total buckets: %s\n" % len(list(results))
return 0
def printError(error):
print error.value
return 1
def finish(return_code):
reactor.stop(exitStatus=return_code)
options, args = parse_options(__doc__.strip())
creds = AWSCredentials(options.access_key, options.secret_key)
region = AWSServiceRegion(
creds=creds, region=options.region, s3_uri=options.url)
client = region.get_s3_client()
d = client.list_buckets()
d.addCallback(printResults)
d.addErrback(printError)
d.addCallback(finish)
# We use a custom reactor so that we can return the exit status from
# reactor.run().
sys.exit(reactor.run())
|