#!/usr/bin/env python import hashlib import os import sys import tarfile import urllib 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 url = 'https://fixmystreet-bundle-cache.s3.amazonaws.com/%s' % wanted_filename try: urllib.urlretrieve(url, wanted_filename) if tarfile.is_tarfile(wanted_filename): tfile = tarfile.open(wanted_filename) tfile.extractall() print "Cached copy found and extracted" sys.exit(0) else: os.remove(wanted_filename) except IOError: os.remove(wanted_filename) print "No cached copy found, running carton install..." ret = os.system('vendor/bin/carton install --deployment') if ret: os.system('cat ~/.cpanm/build.log') sys.exit(ret)