4 from botocore.exceptions import ClientError
10 s3 = boto3.client('s3')
12 def AWSError(msg, exception, errno = 0):
13 error(msg + "\n" + str(exception.response['Error']['Message']), errno)
16 # Call S3 to list current buckets
17 response = s3.list_buckets()
19 # Get a list of all bucket names from the response
20 buckets = [bucket['Name'] for bucket in response['Buckets']]
22 # Print out the bucket list
23 display ('Bucket List: {0}'.format(buckets))
25 def createBucket(name):
27 s3.create_bucket(Bucket=name, CreateBucketConfiguration={
28 'LocationConstraint': 'us-west-1'})
29 except ClientError as e:
30 AWSError('Unable to create bucket {0}'.format(name), e, 1)
33 #display (__name__ + ':', nolinefeed=True)
37 print 'Command entered' + cmd
39 display ('Command entered ' + cmd)
41 if cmd == 'quit' or cmd == 'exit':
47 createBucket('defaria-aws.com2')