blob: 006ff78492046add633522d9898c813007459441 (
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
34
35
36
37
|
#!/usr/bin/env python
import hashlib
import os
import site
import subprocess
import sys
import tarfile
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
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"
|