Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfabfile.py
More file actions
Latest commit
52 lines (36 loc) · 1.21 KB
/
Copy pathfabfile.py
File metadata and controls
52 lines (36 loc) · 1.21 KB
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
44
45
46
47
48
49
50
51
52
importos
fromfabric.apiimport*
fromfabric.contribimport*
fromboto.s3.connectionimportS3Connection
ifnothasattr(env, 'user'):
env.user='ubuntu'
ifnothasattr(env, 'app_name'):
env.app_name='dev.typecode.com'
ifnothasattr(env, 'aws_id'):
env.aws_id=None
ifnothasattr(env, 'aws_key'):
env.aws_key=None
ifnothasattr(env, 'aws_bucket'):
env.aws_bucket=None
ifnothasattr(env, 'build_number'):
env.build_number=None
s3_conn=S3Connection(aws_access_key_id=env.aws_id, aws_secret_access_key=env.aws_key)
s3_headers= {'x-amz-acl': 'public-read'}
defupload_www_to_s3():
bucket=s3_conn.create_bucket(env.aws_bucket)
namelist= []
forroot, dirs, filesinos.walk('./www'):
iffiles:
path=os.path.relpath(root, 'www')
namelist+= [os.path.normpath(os.path.join(path, f)) forfinfiles]
print'Uploading: '
fornameinnamelist:
my_path=os.path.join('./www', name)
print' '+my_path
content=open(my_path)
key=bucket.new_key(name)
key.set_contents_from_file(content, s3_headers)
content.close()
defdeploy():
ifenv.aws_bucket:
upload_www_to_s3()