MCPcopy Create free account
hub / github.com/apache/solr / attemptDownload

Function attemptDownload

dev-tools/scripts/scriptutil.py:208–228  ·  view source on GitHub ↗
(urlString, fileName)

Source from the content-addressed store, hash-verified

206
207
208def attemptDownload(urlString, fileName):
209 raw_request = urllib.request.Request(urlString)
210 raw_request.add_header('User-Agent', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Firefox/78.0')
211 raw_request.add_header('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8')
212 fIn = urllib.request.urlopen(raw_request)
213 fOut = open(fileName, 'wb')
214 success = False
215 try:
216 while True:
217 s = fIn.read(65536)
218 if s == b'':
219 break
220 fOut.write(s)
221 fOut.close()
222 fIn.close()
223 success = True
224 finally:
225 fIn.close()
226 fOut.close()
227 if not success:
228 os.remove(fileName)
229
230version_prop_re = re.compile(r'baseVersion\s*=\s*([\'"])(.*)\1')
231

Callers 1

downloadFunction · 0.85

Calls 4

readMethod · 0.65
writeMethod · 0.65
closeMethod · 0.65
removeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…