當前位置: 首頁>>代碼示例>>Python>>正文


Python FileDownloader.download_verify_return方法代碼示例

本文整理匯總了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
開發者ID:dlernstrom,項目名稱:PyUpdater,代碼行數:34,代碼來源:patcher.py

示例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
開發者ID:awesome-python,項目名稱:PyUpdater,代碼行數:9,代碼來源:test_downloader.py

示例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
開發者ID:JMSwag,項目名稱:PyUpdater,代碼行數:49,代碼來源:patcher.py

示例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
開發者ID:timeyyy,項目名稱:PyUpdater,代碼行數:22,代碼來源:__init__.py

示例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
開發者ID:awesome-python,項目名稱:PyUpdater,代碼行數:6,代碼來源:test_downloader.py

示例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
開發者ID:awesome-python,項目名稱:PyUpdater,代碼行數:7,代碼來源:test_downloader.py

示例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
開發者ID:awesome-python,項目名稱:PyUpdater,代碼行數:7,代碼來源:test_downloader.py

示例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
開發者ID:awesome-python,項目名稱:PyUpdater,代碼行數:7,代碼來源:test_downloader.py

示例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
開發者ID:awesome-python,項目名稱:PyUpdater,代碼行數:6,代碼來源:test_downloader.py

示例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
開發者ID:Encryptabit,項目名稱:PyUpdater,代碼行數:6,代碼來源:test_downloader.py

示例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
開發者ID:Encryptabit,項目名稱:PyUpdater,代碼行數:6,代碼來源:test_downloader.py


注:本文中的pyupdater.client.downloader.FileDownloader.download_verify_return方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。