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