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
14
def printResults(results):
18
def printError(error):
23
def finish(return_code):
24
reactor.stop(exitStatus=return_code)
27
options, args = parse_options(__doc__.strip())
28
if options.bucket is None:
29
print "Error Message: A bucket name is required."
31
creds = AWSCredentials(options.access_key, options.secret_key)
32
region = AWSServiceRegion(
33
creds=creds, region=options.region, s3_uri=options.url)
34
client = region.get_s3_client()
36
d = client.create_bucket(options.bucket)
37
d.addCallback(printResults)
38
d.addErrback(printError)
40
# We use a custom reactor so that we can return the exit status from
42
sys.exit(reactor.run())