ยปCore Development>Code coverage>Tools/msi/purge.py

Python code coverage for Tools/msi/purge.py

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