-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcheck_sync_stats.py
executable file
·40 lines (32 loc) · 1002 Bytes
/
check_sync_stats.py
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
#!/usr/bin/env python
import boto.exception
import boto.s3.connection
import boto.s3.acl
import argparse
from boto.connection import AWSAuthConnection
parser = argparse.ArgumentParser(description='create objects')
parser.add_argument('--num', type=int, action='store', default=100 )
args = parser.parse_args()
s3_access_key=os.environ['S3_ACCESS_KEY_ID']
s3_secret_key=os.environ['S3_SECRET_ACCESS_KEY']
connection = boto.s3.connection.S3Connection(
aws_access_key_id=s3_access_key,
aws_secret_access_key=s3_secret_key,
is_secure=False,
port=8000,
host='127.0.0.1',
calling_format=boto.s3.connection.OrdinaryCallingFormat(),
)
print 'create a bucket'
bucket = connection.create_bucket('bucket10')
for i in range(args.num):
print 'creating obj'+ `i`
obj = boto.s3.key.Key(bucket)
obj.key = 'obj' + `i`
obj.set_contents_from_string('This is a test of S3')
print 'list objects'
i = 0
for k in bucket.list():
print 'obj ' + `i`
print k
i = i + 1