aboutsummaryrefslogtreecommitdiffstats
path: root/.travis/install
blob: 8514e801d3b2188e8d3f5d08779e22888893db79 (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 hashlib
import os
import sys
import tarfile

import boto
from boto.s3.key import Key
from boto.exception import S3ResponseError

root = os.path.join(os.path.dirname(__file__), '..')
with open(os.path.join(root, 'cpanfile.snapshot')) as cpanfile:
    hash = hashlib.md5(cpanfile.read()).hexdigest()
wanted_filename = 'fixmystreet-local-%s.tgz' % hash

conn = boto.connect_s3()
bucket = conn.get_bucket('fixmystreet-bundle-cache')

k = Key(bucket)
k.key = wanted_filename
try:
    k.get_contents_to_filename(wanted_filename)
    if tarfile.is_tarfile(wanted_filename):
        tfile = tarfile.open(wanted_filename)
        tfile.extractall()
        sys.exit(0)
except S3ResponseError:
    os.remove(wanted_filename)

print "No cached copy found, running carton install..."
os.system('cpanm -q Carton')
os.system('carton install --deployment')