1 | n/a | # Purges the Fastly cache for Windows download files |
---|
2 | n/a | # |
---|
3 | n/a | # Usage: |
---|
4 | n/a | # py -3 purge.py 3.5.1rc1 |
---|
5 | n/a | # |
---|
6 | n/a | |
---|
7 | n/a | __author__ = 'Steve Dower <steve.dower@python.org>' |
---|
8 | n/a | __version__ = '1.0.0' |
---|
9 | n/a | |
---|
10 | n/a | import re |
---|
11 | n/a | import sys |
---|
12 | n/a | |
---|
13 | n/a | from urllib.request import * |
---|
14 | n/a | |
---|
15 | n/a | VERSION_RE = re.compile(r'(\d+\.\d+\.\d+)(\w+\d+)?$') |
---|
16 | n/a | |
---|
17 | n/a | try: |
---|
18 | n/a | m = VERSION_RE.match(sys.argv[1]) |
---|
19 | n/a | if not m: |
---|
20 | n/a | print('Invalid version:', sys.argv[1]) |
---|
21 | n/a | print('Expected something like "3.5.1rc1"') |
---|
22 | n/a | sys.exit(1) |
---|
23 | n/a | except LookupError: |
---|
24 | n/a | print('Missing version argument. Expected something like "3.5.1rc1"') |
---|
25 | n/a | sys.exit(1) |
---|
26 | n/a | |
---|
27 | n/a | URL = "https://www.python.org/ftp/python/{}/".format(m.group(1)) |
---|
28 | n/a | |
---|
29 | n/a | |
---|
30 | n/a | FILES = [ |
---|
31 | n/a | "core.msi", |
---|
32 | n/a | "core_d.msi", |
---|
33 | n/a | "core_pdb.msi", |
---|
34 | n/a | "dev.msi", |
---|
35 | n/a | "dev_d.msi", |
---|
36 | n/a | "doc.msi", |
---|
37 | n/a | "exe.msi", |
---|
38 | n/a | "exe_d.msi", |
---|
39 | n/a | "exe_pdb.msi", |
---|
40 | n/a | "launcher.msi", |
---|
41 | n/a | "lib.msi", |
---|
42 | n/a | "lib_d.msi", |
---|
43 | n/a | "lib_pdb.msi", |
---|
44 | n/a | "path.msi", |
---|
45 | n/a | "pip.msi", |
---|
46 | n/a | "tcltk.msi", |
---|
47 | n/a | "tcltk_d.msi", |
---|
48 | n/a | "tcltk_pdb.msi", |
---|
49 | n/a | "test.msi", |
---|
50 | n/a | "test_d.msi", |
---|
51 | n/a | "test_pdb.msi", |
---|
52 | n/a | "tools.msi", |
---|
53 | n/a | "Windows6.0-KB2999226-x64.msu", |
---|
54 | n/a | "Windows6.0-KB2999226-x86.msu", |
---|
55 | n/a | "Windows6.1-KB2999226-x64.msu", |
---|
56 | n/a | "Windows6.1-KB2999226-x86.msu", |
---|
57 | n/a | "Windows8.1-KB2999226-x64.msu", |
---|
58 | n/a | "Windows8.1-KB2999226-x86.msu", |
---|
59 | n/a | "Windows8-RT-KB2999226-x64.msu", |
---|
60 | n/a | "Windows8-RT-KB2999226-x86.msu", |
---|
61 | n/a | ] |
---|
62 | n/a | PATHS = [ |
---|
63 | n/a | "python-{}.exe".format(m.group(0)), |
---|
64 | n/a | "python-{}-webinstall.exe".format(m.group(0)), |
---|
65 | n/a | "python-{}-amd64.exe".format(m.group(0)), |
---|
66 | n/a | "python-{}-amd64-webinstall.exe".format(m.group(0)), |
---|
67 | n/a | ] + ["win32{}/{}".format(m.group(2), f) for f in FILES] + ["amd64{}/{}".format(m.group(2), f) for f in FILES] |
---|
68 | n/a | |
---|
69 | n/a | print('Purged:') |
---|
70 | n/a | for n in PATHS: |
---|
71 | n/a | u = URL + n |
---|
72 | n/a | with urlopen(Request(u, method='PURGE', headers={'Fastly-Soft-Purge': 1})) as r: |
---|
73 | n/a | r.read() |
---|
74 | n/a | print(' ', u) |
---|