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


Python downloader.Downloader类代码示例

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


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

示例1: install_setuptools

    def install_setuptools(self):
        options = self.options
        pkgname = self.pkg.name
        if options.no_setuptools:
            logger.log("Skip installation of setuptools.")
            return
        download_url = DISTRIBUTE_SETUP_DLSITE
        filename = Link(download_url).filename
        download_file = os.path.join(PATH_DISTS, filename)

        dl = Downloader()
        dl.download(filename, download_url, download_file)

        install_dir = os.path.join(PATH_PYTHONS, pkgname)
        path_python = os.path.join(install_dir,"bin","python")
        try:
            s = Subprocess(log=self.logfile, cwd=PATH_DISTS, verbose=self.options.verbose)
            logger.info("Installing distribute into %s" % install_dir)
            s.check_call([path_python, filename])
            # installing pip
            easy_install = os.path.join(install_dir, 'bin', 'easy_install')
            if os.path.isfile(easy_install):
                logger.info("Installing pip into %s" % install_dir)
                s.check_call([easy_install, 'pip'])
        except:
            logger.error("Failed to install setuptools. See %s/build.log to see why." % (ROOT))
            logger.log("Skip installation of setuptools.")
开发者ID:Ank1tAggarwal,项目名称:pythonbrew,代码行数:27,代码来源:pythoninstaller.py

示例2: download_unpack

 def download_unpack(self):
     content_type = self.content_type
     if is_html(content_type):
         logger.error("Invalid content-type: `%s`" % content_type)
         sys.exit(1)
     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))
             if os.path.isdir(self.build_dir):
                 shutil.rmtree(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:
         msg = Link(self.download_url).show_msg
         try:
             dl = Downloader()
             dl.download(msg, self.download_url, self.download_file)
         except:
             unlink(self.download_file)
             logger.info("\nInterrupt to abort. `%s`" % (self.download_url))
             sys.exit(1)
     # unpack
     if not unpack_downloadfile(self.content_type, self.download_file, self.build_dir):
         sys.exit(1)
开发者ID:Singletoned,项目名称:pythonbrew,代码行数:27,代码来源:installer.py

示例3: run_command

    def run_command(self, options, args):
        if options.python:
            pkgname = Package(options.python).name
        else:
            pkgname = get_using_python_pkgname()
        if not is_installed(pkgname):
            logger.error('`%s` is not installed.' % pkgname)
            sys.exit(1)
        logger.info('Using %s' % pkgname)
        
        # build a path
        python = os.path.join(PATH_PYTHONS, pkgname, 'bin', 'python')
        
        # Download bootstrap.py
        download_url = BOOTSTRAP_DLSITE
        download_hash = BOOTSTRAP_HASH
        filename = Link(download_url).filename
        bootstrap = os.path.join(os.getcwd(), filename) # fetching into current directory
        try:
            d = Downloader()
            d.download(filename, download_url, bootstrap, download_hash) 
        except:
            e = sys.exc_info()[1]
            logger.error("%s" % (e))
            sys.exit(1)

        # call bootstrap.py
        if subprocess.call([python, bootstrap, '-d']):
            logger.error('Failed to bootstrap.')
            sys.exit(1)

        # call buildout
        subprocess.call(['./bin/buildout'])
开发者ID:steakknife,项目名称:pythonbrew,代码行数:33,代码来源:buildout.py

示例4: install_setuptools

 def install_setuptools(self):
     options = self.options
     pkgname = self.pkg.name
     if options.no_setuptools:
         logger.info("Skip installation setuptools.")
         return
     if re.match("^Python-3.*", pkgname):
         is_python3 = True
     else:
         is_python3 = False
     download_url = DISTRIBUTE_SETUP_DLSITE
     filename = Link(download_url).filename
     download_file = os.path.join(PATH_DISTS, filename)
     
     dl = Downloader()
     dl.download(filename, download_url, download_file)
     
     install_dir = os.path.join(PATH_PYTHONS, pkgname)
     path_python = os.path.join(install_dir,"bin","python")
     try:
         s = Subprocess(log=self.logfile, cwd=PATH_DISTS)
         logger.info("Installing distribute into %s" % install_dir)
         s.check_call("%s %s" % (path_python, filename))
         if os.path.isfile("%s/bin/easy_install" % (install_dir)) and not is_python3:
             logger.info("Installing pip into %s" % install_dir)
             s.check_call("%s/bin/easy_install pip" % (install_dir))
     except:
         logger.error("Failed to install setuptools. See %s/build.log to see why." % (ROOT))
         logger.info("Skip install setuptools.")
开发者ID:Singletoned,项目名称:pythonbrew,代码行数:29,代码来源:installer.py

示例5: run_command_init

 def run_command_init(self):
     if os.path.exists(self._venv):
         logger.info('venv command is already initialized.')
         return
     if not os.access(PATH_DISTS, os.W_OK):
         logger.error("Can not initialize venv command: Permission denied.")
         sys.exit(1)
     d = Downloader()
     download_file = os.path.join(PATH_DISTS, 'virtualenv.tar.gz')
     d.download('virtualenv.tar.gz', VIRTUALENV_DLSITE, download_file)
     logger.info('Extracting virtualenv into %s' % self._venv_dir)
     untar_file(download_file, self._venv_dir)
开发者ID:ampledata,项目名称:pythonbrew,代码行数:12,代码来源:venv.py

示例6: _update_config

 def _update_config(self, options, args):
     # config.cfg update
     # TODO: Automatically create for config.cfg
     download_url = PYTHONBREW_UPDATE_URL_CONFIG
     if not download_url:
         logger.error("Invalid download url in config.cfg. `%s`" % download_url)
         sys.exit(1)
     distname = Link(PYTHONBREW_UPDATE_URL_CONFIG).filename
     download_file = PATH_ETC_CONFIG
     try:
         d = Downloader()
         d.download(distname, download_url, download_file)
     except:
         logger.error("Failed to download. `%s`" % download_url)
         sys.exit(1)
     logger.log("The config.cfg has been updated.")
开发者ID:none-da,项目名称:pythonbrew,代码行数:16,代码来源:update.py

示例7: _update_pythonbrew

    def _update_pythonbrew(self, options, args):
        if options.master:
            version = "master"
        elif options.develop:
            version = "develop"
        else:
            version = get_stable_version()
            # check for version
            if not options.force and Version(version) <= VERSION:
                logger.info("You are already running the installed latest version of pythonbrew.")
                return

        download_url = get_pythonbrew_update_url(version)
        if not download_url:
            logger.error("`pythonbrew-%s` was not found in pypi." % version)
            sys.exit(1)
        headinfo = get_headerinfo_from_url(download_url)
        content_type = headinfo["content-type"]
        if not options.master and not options.develop:
            if not is_gzip(content_type, Link(download_url).filename):
                logger.error("content type should be gzip. content-type:`%s`" % content_type)
                sys.exit(1)

        filename = "pythonbrew-%s" % version
        distname = "%s.tgz" % filename
        download_file = os.path.join(PATH_DISTS, distname)
        try:
            d = Downloader()
            d.download(distname, download_url, download_file)
        except:
            logger.error("Failed to download. `%s`" % download_url)
            sys.exit(1)

        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, "pythonbrew_install.py"), "--upgrade"])
        except:
            logger.error("Failed to update pythonbrew.")
            sys.exit(1)
        logger.info("The pythonbrew has been updated.")
开发者ID:none-da,项目名称:pythonbrew,代码行数:46,代码来源:update.py

示例8: run_command

 def run_command(self, options, args):
     if args:
         version = args[0]
     else:
         version = get_stable_version()
         
     # check for latest version
     if version <= VERSION:
         logger.info("You are already running the installed latest version of pythonbrew.")
         sys.exit()
     
     download_url = get_pythonbrew_update_url(version)
     if not download_url:
         logger.error("`%s` of pythonbrew not found." % version)
         sys.exit(1)
     resp = get_response_from_url(download_url)
     content_type = resp.info()['content-type']
     if not is_gzip(content_type, Link(download_url).filename):
         logger.error("Invalid content-type: `%s`" % content_type)
         sys.exit(1)
     
     filename = "pythonbrew-%s" % version
     distname = "%s.tgz" % filename
     download_file = os.path.join(PATH_DISTS, distname)
     try:
         d = Downloader()
         d.download(distname, download_url, download_file)
     except:
         logger.error("Failed to download. `%s`" % download_url)
         sys.exit(1)
     
     extract_dir = os.path.join(PATH_BUILD, filename)
     rm_r(extract_dir)
     if not unpack_downloadfile(content_type, download_file, extract_dir):
         sys.exit(1)
     
     try:
         installer_path = "%s/pythonbrew" % (extract_dir)
         logger.info("Installing %s into %s" % (extract_dir, ROOT))
         PythonbrewInstaller().install(installer_path)
     except:
         logger.error("Failed to update pythonbrew.")
         raise
         sys.exit(1)
     logger.info("The pythonbrew has been updated.")
开发者ID:nvie,项目名称:pythonbrew,代码行数:45,代码来源:update.py

示例9: _update_pythonbrew

 def _update_pythonbrew(self, options, args):
     # pythonbrew update
     if options.head:
         version = 'head'
     else:
         version = get_stable_version()
         # check for version
         if not options.force and version <= VERSION:
             logger.info("You are already running the installed latest version of pythonbrew.")
             return
     
     download_url = get_pythonbrew_update_url(version)
     if not download_url:
         logger.error("`%s` of pythonbrew not found." % version)
         sys.exit(1)
     headinfo = get_headerinfo_from_url(download_url)
     content_type = headinfo['content-type']
     # head is only for gzip.
     if not options.head and not is_gzip(content_type, Link(download_url).filename):
         logger.error("Invalid content-type: `%s`" % content_type)
         sys.exit(1)
     
     filename = "pythonbrew-%s" % version
     distname = "%s.tgz" % filename
     download_file = os.path.join(PATH_DISTS, distname)
     try:
         d = Downloader()
         d.download(distname, download_url, download_file)
     except:
         logger.error("Failed to download. `%s`" % download_url)
         sys.exit(1)
     
     extract_dir = os.path.join(PATH_BUILD, filename)
     rm_r(extract_dir)
     if not unpack_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('%s %s/pythonbrew_install.py --upgrade' % (sys.executable, extract_dir))
     except:
         logger.error("Failed to update pythonbrew.")
         sys.exit(1)
     logger.info("The pythonbrew has been updated.")
开发者ID:npinto,项目名称:pythonbrew,代码行数:45,代码来源:update.py

示例10: run_command_init

 def run_command_init(self):
     if os.path.exists(self._venv):
         logger.info('Remove virtualenv. (%s)' % self._venv_dir)
         rm_r(self._venv_dir)
     if os.path.exists(self._venv_clone):
         logger.info('Remove virtualenv-clone. (%s)' % self._venv_clone_dir)
         rm_r(self._venv_clone_dir)
     if not os.access(PATH_DISTS, os.W_OK):
         logger.error("Can not initialize venv command: Permission denied.")
         sys.exit(1)
     d = Downloader()
     download_file = os.path.join(PATH_DISTS, 'virtualenv.tar.gz')
     d.download('virtualenv.tar.gz', VIRTUALENV_DLSITE, download_file)
     logger.info('Extracting virtualenv into %s' % self._venv_dir)
     untar_file(download_file, self._venv_dir)
     download_file = os.path.join(PATH_DISTS, 'virtualenv-clone.tar.gz')
     d.download('virtualenv-clone.tar.gz', VIRTUALENV_CLONE_DLSITE, download_file)
     logger.info('Extracting virtualenv-clone into %s' % self._venv_clone_dir)
     untar_file(download_file, self._venv_clone_dir)
开发者ID:Annia,项目名称:pythonbrew,代码行数:19,代码来源:venv.py

示例11: run_command

    def run_command(self, options, args):
        if options.python:
            pkgname = Package(options.python).name
        else:
            pkgname = get_using_python_pkgname()
        if not is_installed(pkgname):
            logger.error('`%s` is not installed.' % pkgnam)
            sys.exit(1)
        logger.info('Using %s' % pkgname)
        
        # build a path
        python = os.path.join(PATH_PYTHONS, pkgname, 'bin', 'python')
        
        # Download bootstrap.py
        download_url = BOOTSTRAP_DLSITE
        filename = Link(download_url).filename
        bootstrap = os.path.join(os.getcwd(), filename) # fetching into current directory
        try:
            d = Downloader()
            d.download(filename, download_url, bootstrap)
        except:
            e = sys.exc_info()[1]
            logger.error("%s" % (e))
            sys.exit(1)

        # call bootstrap.py
        option_boostrap = [python.encode('utf8'), bootstrap, '-d']
        if options.config:
            option_boostrap.extend(['-c', options.config])
        
        
        cmd_bootstrap =' '.join("{0}".format(iter_el) for
                                iter_el in  option_boostrap)
        
        if subprocess.call(shlex.split(cmd_bootstrap.encode('utf8'))):
                logger.error('Failed to bootstrap.')
                sys.exit(1)
        
        # call buildout
        if options.config:
            subprocess.call(['./bin/buildout', '-c', options.config])
        else:
            subprocess.call(['./bin/buildout'])
开发者ID:jmagnusson,项目名称:pythonbrew,代码行数:43,代码来源:buildout.py

示例12: download

 def download(self):
     content_type = self.content_type
     if is_html(content_type):
         logger.error("Invalid content-type: `%s`" % content_type)
         sys.exit(1)
     if os.path.isfile(self.download_file):
         logger.info("Use the previously fetched %s" % (self.download_file))
         return
     msg = Link(self.download_url).show_msg
     try:
         dl = Downloader()
         dl.download(
             msg,
             self.download_url,
             self.download_file
         )
     except:
         unlink(self.download_file)
         logger.info("\nInterrupt to abort. `%s`" % (self.download_url))
         sys.exit(1)
开发者ID:nvie,项目名称:pythonbrew,代码行数:20,代码来源:installer.py

示例13: download_and_extract

 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
         try:
             dl = Downloader()
             dl.download(base_url, self.download_url, self.download_file)
         except:
             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:Ank1tAggarwal,项目名称:pythonbrew,代码行数:21,代码来源:pythoninstaller.py


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