aboutsummaryrefslogtreecommitdiffstats
path: root/.travis/after_script
blob: 2a8b2268d9eaba2e0f34fc40eec0512b730c9d41 (plain)
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
#!/usr/bin/env python

import os
import site
import sys
import tarfile
from utils import get_bundle_filename

wanted_filename = get_bundle_filename()

if os.path.exists(wanted_filename) and os.path.getsize(wanted_filename):
    print "File was downloaded, no need to upload"
    sys.exit()

site.addsitedir(site.getusersitepackages())
os.system('pip install --user boto')

import boto
from boto.s3.key import Key

print "Creating archive..."
tfile = tarfile.open(wanted_filename, 'w:gz')
tfile.add('local')
tfile.close()

print "Uploading archive to S3..."
conn = boto.connect_s3()
bucket = conn.get_bucket('fixmystreet-bundle-cache')
key = Key(bucket)
key.key = wanted_filename
key.set_contents_from_filename(wanted_filename)

print "Completed"