本文整理汇总了Python中pyupdater.client.downloader.FileDownloader.download_verify_return方法的典型用法代码示例。如果您正苦于以下问题:Python FileDownloader.download_verify_return方法的具体用法?Python FileDownloader.download_verify_return怎么用?Python FileDownloader.download_verify_return使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyupdater.client.downloader.FileDownloader
的用法示例。
在下文中一共展示了FileDownloader.download_verify_return方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _download_verify_patches
# 需要导入模块: from pyupdater.client.downloader import FileDownloader [as 别名]
# 或者: from pyupdater.client.downloader.FileDownloader import download_verify_return [as 别名]
def _download_verify_patches(self):
# Downloads & verifies all patches
log.debug('Downloading patches')
downloaded = 0
total = len(self.patch_data)
for p in self.patch_data:
# Initialize downloader
fd = FileDownloader(p['patch_name'], p['patch_urls'],
p['patch_hash'], self.verify)
# Attempt to download resource
data = fd.download_verify_return()
if data is not None:
self.patch_binary_data.append(data)
downloaded += 1
status = {'total': total,
'downloaed': downloaded,
'status': 'downloading'}
self._call_progress_hooks(status)
else:
# Since patches are applied sequentially
# we cannot continue successfully
status = {'total': total,
'downloaded': downloaded,
'status': 'failed to download all patches'}
self._call_progress_hooks(status)
return False
status = {'total': total,
'downloaed': downloaded,
'status': 'finished'}
self._call_progress_hooks(status)
return True
示例2: test_cb
# 需要导入模块: from pyupdater.client.downloader import FileDownloader [as 别名]
# 或者: from pyupdater.client.downloader.FileDownloader import download_verify_return [as 别名]
def test_cb(self):
def cb(status):
pass
fd = FileDownloader(FILENAME, URLS, hexdigest=FILE_HASH,
progress_hooks=[cb], verify=True)
binary_data = fd.download_verify_return()
assert binary_data is not None
示例3: _download_verify_patches
# 需要导入模块: from pyupdater.client.downloader import FileDownloader [as 别名]
# 或者: from pyupdater.client.downloader.FileDownloader import download_verify_return [as 别名]
def _download_verify_patches(self):
# Downloads & verifies all patches
log.debug('Downloading patches')
downloaded = 0
percent = 0
total = len(self.patch_data)
temp_dir = tempfile.gettempdir()
for p in self.patch_data:
# Don't write temp files to cwd
with ChDir(temp_dir):
fd = FileDownloader(p['patch_name'], p['patch_urls'],
hexdigest=p['patch_hash'], verify=self.verify,
max_download_retries=self.max_download_retries,
urllb3_headers=self.urllib3_headers)
# Attempt to download resource
data = fd.download_verify_return()
percent = int((float(downloaded + 1) / float(total)) * 100)
percent = '{0:.1f}'.format(percent)
if data is not None:
self.patch_binary_data.append(data)
downloaded += 1
status = {'total': total,
'downloaded': downloaded,
'percent_complete': percent,
'status': 'downloading'}
self._call_progress_hooks(status)
else:
# Since patches are applied sequentially
# we cannot continue successfully
status = {'total': total,
'downloaded': downloaded,
'percent_complete': percent,
'status': 'failed to download all patches'}
self._call_progress_hooks(status)
return False
status = {'total': total,
'downloaded': downloaded,
'percent_complete': percent,
'status': 'finished'}
self._call_progress_hooks(status)
return True
示例4: _download_manifest
# 需要导入模块: from pyupdater.client.downloader import FileDownloader [as 别名]
# 或者: from pyupdater.client.downloader.FileDownloader import download_verify_return [as 别名]
def _download_manifest(self):
log.info('Downloading online version file')
try:
fd = FileDownloader(self.version_file, self.update_urls,
verify=self.verify)
data = fd.download_verify_return()
try:
decompressed_data = gzip_decompress(data)
except IOError:
log.error('Failed to decompress gzip file')
# Will be caught down below. Just logging the error
raise
log.info('Version file download successful')
# Writing version file to application data directory
self._write_manifest_2_filesystem(decompressed_data)
return decompressed_data
except Exception as err:
log.error('Version file download failed')
log.debug(str(err), exc_info=True)
return None
示例5: test_good_conent_length
# 需要导入模块: from pyupdater.client.downloader import FileDownloader [as 别名]
# 或者: from pyupdater.client.downloader.FileDownloader import download_verify_return [as 别名]
def test_good_conent_length(self):
fd = FileDownloader(FILENAME, URLS, hexdigest=FILE_HASH, verify=True)
fd.download_verify_return()
assert fd.content_length == 2387
示例6: test_bad_url
# 需要导入模块: from pyupdater.client.downloader import FileDownloader [as 别名]
# 或者: from pyupdater.client.downloader.FileDownloader import download_verify_return [as 别名]
def test_bad_url(self):
fd = FileDownloader(FILENAME, ['bad url'], hexdigest='bad hash',
verify=True)
binary_data = fd.download_verify_return()
assert binary_data is None
示例7: test_url_with_spaces
# 需要导入模块: from pyupdater.client.downloader import FileDownloader [as 别名]
# 或者: from pyupdater.client.downloader.FileDownloader import download_verify_return [as 别名]
def test_url_with_spaces(self):
fd = FileDownloader(FILENAME_WITH_SPACES, URLS,
hexdigest=FILE_HASH, verify=True)
binary_data = fd.download_verify_return()
assert binary_data is not None
示例8: test_return_fail
# 需要导入模块: from pyupdater.client.downloader import FileDownloader [as 别名]
# 或者: from pyupdater.client.downloader.FileDownloader import download_verify_return [as 别名]
def test_return_fail(self):
fd = FileDownloader(FILENAME, URLS,
'JKFEIFJILEFJ983NKFNKL', verify=True)
binary_data = fd.download_verify_return()
assert binary_data is None
示例9: test_return
# 需要导入模块: from pyupdater.client.downloader import FileDownloader [as 别名]
# 或者: from pyupdater.client.downloader.FileDownloader import download_verify_return [as 别名]
def test_return(self):
fd = FileDownloader(FILENAME, URLS, FILE_HASH, verify=True)
binary_data = fd.download_verify_return()
assert binary_data is not None
示例10: test_good_conent_length
# 需要导入模块: from pyupdater.client.downloader import FileDownloader [as 别名]
# 或者: from pyupdater.client.downloader.FileDownloader import download_verify_return [as 别名]
def test_good_conent_length(self):
fd = FileDownloader(FILENAME, URL, FILE_HASH, verify=False)
fd.download_verify_return()
assert fd.content_length == 60000
示例11: test_bad_url
# 需要导入模块: from pyupdater.client.downloader import FileDownloader [as 别名]
# 或者: from pyupdater.client.downloader.FileDownloader import download_verify_return [as 别名]
def test_bad_url(self):
fd = FileDownloader(FILENAME, 'bad url', 'bad hash', verify=False)
binary_data = fd.download_verify_return()
assert binary_data is None