MCPcopy Create free account
hub / github.com/PyQt5/PyQtClient / download

Method download

Utils/GitThread.py:341–360  ·  view source on GitHub ↗
(self, file, url)

Source from the content-addressed store, hash-verified

339 zipfile.close()
340
341 def download(self, file, url):
342 AppLog.debug('start download {}'.format(url))
343 with closing(requests.get(url, stream=True)) as response:
344 # 单次请求最大值
345 chunk_size = 1024
346 # 内容体总大小
347 content_size = int(response.headers['content-length'])
348 data_count = 0
349 Signals.updateProgressChanged.emit(0, 0, content_size)
350 AppLog.debug('content_size: {}'.format(content_size))
351 with open(file, 'wb') as fp:
352 for data in response.iter_content(chunk_size=chunk_size):
353 fp.write(data)
354 data_count = data_count + len(data)
355 if content_size > 0:
356 Signals.updateProgressChanged.emit(
357 data_count, 0, content_size)
358 # 解压
359 self.unzip(file)
360 AppLog.debug('download {} end'.format(file))
361
362 def run(self):
363 for url_ver, url_zip in self.UpdateUrl:

Callers 1

runMethod · 0.95

Calls 1

unzipMethod · 0.95

Tested by

no test coverage detected