Debian Codegraph @

Tools/msi/purge.py

raw
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 <[email protected]>'
8 __version__ = '1.0.0'
9
10 import re
11 import sys
12
13 from urllib.request import Request, urlopen
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 ]
55 PATHS = [
56 "python-{}.exe".format(m.group(0)),
57 "python-{}-webinstall.exe".format(m.group(0)),
58 "python-{}-amd64.exe".format(m.group(0)),
59 "python-{}-amd64-webinstall.exe".format(m.group(0)),
60 "python-{}-arm64.exe".format(m.group(0)),
61 "python-{}-arm64-webinstall.exe".format(m.group(0)),
62 "python-{}-embed-amd64.zip".format(m.group(0)),
63 "python-{}-embed-win32.zip".format(m.group(0)),
64 "python-{}-embed-arm64.zip".format(m.group(0)),
65 *["win32{}/{}".format(REL, f) for f in FILES],
66 *["amd64{}/{}".format(REL, f) for f in FILES],
67 *["arm64{}/{}".format(REL, f) for f in FILES],
68 ]
69 PATHS = PATHS + [p + ".asc" for p in PATHS]
70
71 print('Purged:')
72 for n in PATHS:
73 u = URL + n
74 with urlopen(Request(u, method='PURGE', headers={'Fastly-Soft-Purge': 1})) as r:
75 r.read()
76 print(' ', u)