forked from getlantern/lantern
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcopys3file.py
executable file
·40 lines (34 loc) · 1.07 KB
/
copys3file.py
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
#!/usr/bin/env python
import sys
import boto
from boto.s3.key import Key
key = str(sys.argv[1])
if key.endswith('dmg'):
latest = 'latest.dmg'
elif key.endswith('exe'):
latest = 'latest.exe'
elif key.endswith('32-bit.deb'):
latest = 'latest-32.deb'
elif key.endswith('64-bit.deb'):
latest = 'latest-64.deb'
else:
print 'File name with full version required. .deb files should end in 32-bit.deb or 64-bit.deb'
sys.exit(1)
conn = boto.connect_s3()
b = conn.get_bucket('lantern')
k = Key(b)
k.key = key
k.copy('lantern', latest, preserve_acl=True)
# Since we've just updated the fixed name 'lantest.x' file in our bucket,
# we need to make sure to invalidate it on cloudfront in case anyone's
# using it.
print 'Invalidating latest installers on CloudFront...'
c = boto.connect_cloudfront()
#rs = c.get_all_distributions()
#ds = rs[1]
#distro = ds.get_distribution()
#print distro.domain_name
#print distro.id
paths = [latest]
inval_req = c.create_invalidation_request(u'E1D7VOTZEUYRZT', paths)
status = c.invalidation_request_status(u'E1D7VOTZEUYRZT', inval_req.id)