• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
10import re
11import sys
12
13from urllib.request import *
14
15VERSION_RE = re.compile(r'(\d+\.\d+\.\d+)([A-Za-z_]+\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))
28REL = m.group(2) or ''
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    "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]
63PATHS = [
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-{}-embed-amd64.zip".format(m.group(0)),
69    "python-{}-embed-win32.zip".format(m.group(0)),
70] + ["win32{}/{}".format(REL, f) for f in FILES] + ["amd64{}/{}".format(REL, f) for f in FILES]
71PATHS = PATHS + [p + ".asc" for p in PATHS]
72
73print('Purged:')
74for n in PATHS:
75    u = URL + n
76    with urlopen(Request(u, method='PURGE', headers={'Fastly-Soft-Purge': 1})) as r:
77        r.read()
78    print('  ', u)
79