MCPcopy Index your code
hub / github.com/nodejs/node / retrievefile

Function retrievefile

tools/configure.d/nodedownload.py:28–44  ·  view source on GitHub ↗

fetch file 'url' as 'targetfile'. Return targetfile or throw.

(url, targetfile)

Source from the content-addressed store, hash-verified

26 formatSize(count*size)))
27
28def retrievefile(url, targetfile):
29 """fetch file 'url' as 'targetfile'. Return targetfile or throw."""
30 try:
31 sys.stdout.write(' <%s>\nConnecting...\r' % url)
32 sys.stdout.flush()
33 opener = build_opener()
34 opener.addheaders = [('User-agent', f'Python-urllib/{sys.version_info.major}.{sys.version_info.minor} node.js/configure')]
35 install_opener(opener)
36 urlretrieve(url, targetfile, reporthook=reporthook)
37 print('') # clear the line
38 return targetfile
39 except IOError as err:
40 print(' ** IOError %s\n' % err)
41 return None
42 except:
43 print(' ** Error occurred while downloading\n <%s>' % url)
44 raise
45
46def findHash(dict):
47 """Find an available hash type."""

Callers

nothing calls this directly

Calls 3

flushMethod · 0.65
printFunction · 0.50
writeMethod · 0.45

Tested by

no test coverage detected