当前位置: 首页>>代码示例>>Python>>正文


Python Downloader.fetch方法代码示例

本文整理汇总了Python中pythonz.downloader.Downloader.fetch方法的典型用法代码示例。如果您正苦于以下问题:Python Downloader.fetch方法的具体用法?Python Downloader.fetch怎么用?Python Downloader.fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pythonz.downloader.Downloader的用法示例。


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

示例1: run_command

# 需要导入模块: from pythonz.downloader import Downloader [as 别名]
# 或者: from pythonz.downloader.Downloader import fetch [as 别名]
    def run_command(self, options, args):
        headinfo = Downloader.read_head_info(PYTHONZ_UPDATE_URL)
        content_type = headinfo["content-type"]
        filename = "pythonz-latest"
        distname = "%s.tgz" % filename
        download_file = os.path.join(PATH_DISTS, distname)
        # Remove old tarball
        unlink(download_file)
        logger.info("Downloading %s as %s" % (distname, download_file))
        try:
            Downloader.fetch(PYTHONZ_UPDATE_URL, download_file)
        except DownloadError:
            unlink(download_file)
            logger.error("Failed to download. `%s`" % PYTHONZ_UPDATE_URL)
            sys.exit(1)
        except:
            unlink(download_file)
            raise

        extract_dir = os.path.join(PATH_BUILD, filename)
        rm_r(extract_dir)
        if not extract_downloadfile(content_type, download_file, extract_dir):
            sys.exit(1)

        try:
            logger.info("Installing %s into %s" % (extract_dir, ROOT))
            s = Subprocess()
            s.check_call([sys.executable, os.path.join(extract_dir, "pythonz_install.py"), "--upgrade"])
        except:
            logger.error("Failed to update pythonz.")
            sys.exit(1)
        logger.info("pythonz has been updated.")
开发者ID:simudream,项目名称:pythonz,代码行数:34,代码来源:update.py

示例2: download

# 需要导入模块: from pythonz.downloader import Downloader [as 别名]
# 或者: from pythonz.downloader.Downloader import fetch [as 别名]
 def download(self):
     if os.path.isfile(self.download_file) and sha256(self.download_file) == self.expected_sha256:
         logger.info("Use the previously fetched %s" % (self.download_file))
     else:
         base_url = Link(self.download_url).base_url
         logger.info("Downloading %s as %s" % (base_url, self.download_file))
         try:
             Downloader.fetch(self.download_url, self.download_file, self.expected_sha256)
         except DownloadError:
             logger.error("Failed to download.\n%s" % (sys.exc_info()[1]))
             sys.exit(1)
开发者ID:simudream,项目名称:pythonz,代码行数:13,代码来源:pythoninstaller.py

示例3: download

# 需要导入模块: from pythonz.downloader import Downloader [as 别名]
# 或者: from pythonz.downloader.Downloader import fetch [as 别名]
 def download(self):
     if os.path.isfile(self.download_file):
         logger.info("Use the previously fetched %s" % (self.download_file))
     else:
         base_url = Link(self.download_url).base_url
         logger.info("Downloading %s as %s" % (base_url, self.download_file))
         try:
             Downloader.fetch(self.download_url, self.download_file)
         except DownloadError:
             unlink(self.download_file)
             logger.error("Failed to download.\n%s" % (sys.exc_info()[1]))
             sys.exit(1)
         except:
             unlink(self.download_file)
             raise
开发者ID:totakke,项目名称:pythonz,代码行数:17,代码来源:pythoninstaller.py

示例4: _update_config

# 需要导入模块: from pythonz.downloader import Downloader [as 别名]
# 或者: from pythonz.downloader.Downloader import fetch [as 别名]
 def _update_config(self, options, args):
     # config.cfg update
     # TODO: Automatically create for config.cfg
     download_url = PYTHONZ_UPDATE_URL_CONFIG
     if not download_url:
         logger.error("Invalid download url in config.cfg. `%s`" % download_url)
         sys.exit(1)
     distname = Link(PYTHONZ_UPDATE_URL_CONFIG).filename
     download_file = PATH_ETC_CONFIG
     logger.info("Downloading %s as %s" % (distname, download_file))
     try:
         Downloader.fetch(download_url, download_file)
     except DownloadError:
         logger.error("Failed to download. `%s`" % download_url)
         sys.exit(1)
     logger.log("The config.cfg has been updated.")
开发者ID:msabramo,项目名称:pythonz,代码行数:18,代码来源:update.py

示例5: download_and_extract

# 需要导入模块: from pythonz.downloader import Downloader [as 别名]
# 或者: from pythonz.downloader.Downloader import fetch [as 别名]
 def download_and_extract(self):
     if is_file(self.download_url):
         path = fileurl_to_path(self.download_url)
         if os.path.isdir(path):
             logger.info('Copying %s into %s' % (path, self.build_dir))
             shutil.copytree(path, self.build_dir)
             return
     if os.path.isfile(self.download_file):
         logger.info("Use the previously fetched %s" % (self.download_file))
     else:
         base_url = Link(self.download_url).base_url
         logger.info("Downloading %s as %s" % (base_url, self.download_file))
         try:
             Downloader.fetch(self.download_url, self.download_file)
         except DownloadError:
             unlink(self.download_file)
             logger.error("Failed to download.\n%s" % (sys.exc_info()[1]))
             sys.exit(1)
     # extracting
     if not extract_downloadfile(self.content_type, self.download_file, self.build_dir):
         sys.exit(1)
开发者ID:tanaka-takayoshi,项目名称:pythonz,代码行数:23,代码来源:pythoninstaller.py


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