blob: 76dbc49ae82205ebe72abd42e30222d4da8b29f4 [file] [log] [blame]
Steve Dower2e4cdb62016-06-27 12:30:48 -07001# 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
10import re
11import sys
12
13from urllib.request import *
14
15VERSION_RE = re.compile(r'(\d+\.\d+\.\d+)(\w+\d+)?$')
16
17try:
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)
23except LookupError:
24 print('Missing version argument. Expected something like "3.5.1rc1"')
25 sys.exit(1)
26
27URL = "https://www.python.org/ftp/python/{}/".format(m.group(1))
28
29
30FILES = [
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 "Windows6.0-KB2999226-x64.msu",
54 "Windows6.0-KB2999226-x86.msu",
55 "Windows6.1-KB2999226-x64.msu",
56 "Windows6.1-KB2999226-x86.msu",
57 "Windows8.1-KB2999226-x64.msu",
58 "Windows8.1-KB2999226-x86.msu",
59 "Windows8-RT-KB2999226-x64.msu",
60 "Windows8-RT-KB2999226-x86.msu",
61]
62PATHS = [
63 "python-{}.exe".format(m.group(0)),
64 "python-{}-webinstall.exe".format(m.group(0)),
65 "python-{}-amd64.exe".format(m.group(0)),
66 "python-{}-amd64-webinstall.exe".format(m.group(0)),
67] + ["win32{}/{}".format(m.group(2), f) for f in FILES] + ["amd64{}/{}".format(m.group(2), f) for f in FILES]
68
69print('Purged:')
70for n in PATHS:
71 u = URL + n
72 with urlopen(Request(u, method='PURGE', headers={'Fastly-Soft-Purge': 1})) as r:
73 r.read()
74 print(' ', u)