MCPcopy Index your code
hub / github.com/python/cpython / _download_src

Method _download_src

Tools/ssl/multissltests.py:268–292  ·  view source on GitHub ↗

Download sources

(self)

Source from the content-addressed store, hash-verified

266 return out.strip().decode("utf-8")
267
268 def _download_src(self):
269 """Download sources"""
270 src_dir = os.path.dirname(self.src_file)
271 if not os.path.isdir(src_dir):
272 os.makedirs(src_dir)
273 data = None
274 for url_template in self.url_templates:
275 url = url_template.format(v=self.version, s=self.short_version)
276 log.info("Downloading from {}".format(url))
277 try:
278 req = urlopen(url)
279 # KISS, read all, write all
280 data = req.read()
281 except HTTPError as e:
282 log.error(
283 "Download from {} has from failed: {}".format(url, e)
284 )
285 else:
286 log.info("Successfully downloaded from {}".format(url))
287 break
288 if data is None:
289 raise ValueError("All download URLs have failed")
290 log.info("Storing {}".format(self.src_file))
291 with open(self.src_file, "wb") as f:
292 f.write(data)
293
294 def _unpack_src(self):
295 """Unpack tar.gz bundle"""

Callers 1

installMethod · 0.95

Calls 9

urlopenFunction · 0.85
openFunction · 0.50
dirnameMethod · 0.45
isdirMethod · 0.45
formatMethod · 0.45
infoMethod · 0.45
readMethod · 0.45
errorMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected