• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python downloader.FileDownloader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyupdater.client.downloader.FileDownloader的典型用法代码示例。如果您正苦于以下问题:Python FileDownloader类的具体用法?Python FileDownloader怎么用?Python FileDownloader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了FileDownloader类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_cb

 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,代码行数:7,代码来源:test_downloader.py


示例2: _download_verify_patches

    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,代码行数:32,代码来源:patcher.py


示例3: test_basic_auth

 def test_basic_auth(self):
     headers = {'basic_auth': 'user:pass'}
     fd = FileDownloader('test', ['test'], urllb3_headers=headers)
     http = fd._get_http_pool(secure=True)
     sc = http.request('GET',
                       'https://httpbin.org/basic-auth/user/pass').status
     assert sc == 200
开发者ID:JMSwag,项目名称:PyUpdater,代码行数:7,代码来源:test_downloader.py


示例4: test_bad_content_length

    def test_bad_content_length(self):
        class FakeHeaders(object):
            headers = {}

        fd = FileDownloader(FILENAME, URLS, hexdigest=FILE_HASH, verify=True)
        data = FakeHeaders()
        assert fd._get_content_length(data) is None
开发者ID:JMSwag,项目名称:PyUpdater,代码行数:7,代码来源:test_downloader.py


示例5: _full_update

    def _full_update(self):
        log.debug('Starting full update')
        file_hash = self._get_file_hash_from_manifest()

        with dsdev_utils.paths.ChDir(self.update_folder):
            log.debug('Downloading update...')
            fd = FileDownloader(self.filename, self.update_urls,
                                hexdigest=file_hash, verify=self.verify,
                                progress_hooks=self.progress_hooks)
            result = fd.download_verify_write()
            if result:
                log.debug('Download Complete')
                return True
            else:  # pragma: no cover
                log.debug('Failed To Download Latest Version')
                return False
开发者ID:smazoyer,项目名称:PyUpdater,代码行数:16,代码来源:updates.py


示例6: _download_verify_patches

    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,代码行数:47,代码来源:patcher.py


示例7: _download_manifest

 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,代码行数:20,代码来源:__init__.py


示例8: _full_update

    def _full_update(self, name):
        log.info('Starting full update')
        latest = get_highest_version(name, self.platform, self.easy_data)

        filename = get_filename(name, latest, self.platform, self.easy_data)

        hash_key = '{}*{}*{}*{}*{}'.format(self.updates_key, name,
                                           latest, self.platform,
                                           'file_hash')
        file_hash = self.easy_data.get(hash_key)

        with jms_utils.paths.ChDir(self.update_folder):
            log.info('Downloading update...')
            fd = FileDownloader(filename, self.update_urls,
                                file_hash, self.verify, self.progress_hooks)
            result = fd.download_verify_write()
            if result:
                log.info('Download Complete')
                return True
            else:  # pragma: no cover
                log.error('Failed To Download Latest Version')
                return False
开发者ID:timeyyy,项目名称:PyUpdater,代码行数:22,代码来源:updates.py


示例9: test_good_conent_length

 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,代码行数:4,代码来源:test_downloader.py


示例10: test_bad_url

 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,代码行数:5,代码来源:test_downloader.py


示例11: test_url_with_spaces

 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,代码行数:5,代码来源:test_downloader.py


示例12: test_return_fail

 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,代码行数:5,代码来源:test_downloader.py


示例13: test_return

 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,代码行数:4,代码来源:test_downloader.py


示例14: test_good_conent_length

 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,代码行数:4,代码来源:test_downloader.py


示例15: test_bad_content_length

 def test_bad_content_length(self):
     class FakeHeaders(object):
         headers = {}
     fd = FileDownloader(FILENAME, URL, FILE_HASH, verify=False)
     data = FakeHeaders()
     assert fd._get_content_length(data) == 100001
开发者ID:Encryptabit,项目名称:PyUpdater,代码行数:6,代码来源:test_downloader.py


示例16: test_bad_url

 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,代码行数:4,代码来源:test_downloader.py



注:本文中的pyupdater.client.downloader.FileDownloader类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python api_resources.File类代码示例发布时间:2022-05-27
下一篇:
Python requirements.Requirement类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap