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


Python util.Subprocess类代码示例

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


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

示例3: patch

 def patch(self):
     version = self.pkg.version
     try:
         s = Subprocess(log=self.logfile, cwd=self.build_dir)
         patches = []
         if is_macosx_snowleopard():
             if is_python24(version):
                 patch_dir = os.path.join(PATH_PATCHES_MACOSX_PYTHON24,'files')
                 patches = ['patch-configure', 'patch-Makefile.pre.in',
                            'patch-Lib-cgi.py', 'patch-Lib-site.py',
                            'patch-setup.py', 'patch-Include-pyport.h',
                            'patch-Mac-OSX-Makefile.in', 'patch-Mac-OSX-IDLE-Makefile.in',
                            'patch-Mac-OSX-PythonLauncher-Makefile.in', 'patch-configure-badcflags.diff',
                            'patch-configure-arch_only.diff', 'patch-macosmodule.diff',
                            'patch-mactoolboxglue.diff', 'patch-pymactoolbox.diff']
             elif is_python25(version):
                 patch_dir = os.path.join(PATH_PATCHES_MACOSX_PYTHON25,'files')
                 patches = ['patch-Makefile.pre.in.diff', 'patch-Lib-cgi.py.diff',
                            'patch-Lib-distutils-dist.py.diff', 'patch-setup.py.diff',
                            'patch-configure-badcflags.diff', 'patch-configure-arch_only.diff',
                            'patch-64bit.diff', 'patch-pyconfig.h.in.diff',
                            'patch-Modules-posixmodule.c.diff']
         if patches:
             logger.info("Patching %s" % self.pkg.name)
             for patch in patches:
                 s.check_call("patch -p0 < %s" % os.path.join(patch_dir, patch))
     except:
         logger.error("Failed to patch `%s`" % self.build_dir)
         sys.exit(1)
开发者ID:nvie,项目名称:pythonbrew,代码行数:29,代码来源:installer.py

示例4: run_command_clone

    def run_command_clone(self, options, args):
        if len(args) < 3:
            logger.error("Unrecognized command line argument: ( 'pythonbrew venv clone <source> <target>' )")
            sys.exit(1)
        if not os.access(PATH_VENVS, os.W_OK):
            logger.error("Can not clone a virtual environment in %s.\nPermission denied." % PATH_VENVS)
            sys.exit(1)
        if not self._pkgname:
            logger.error("Unknown python version: ( 'pythonbrew venv clone <source> <target> -p VERSION' )")
            sys.exit(1)

        source, target = args[1], args[2]
        source_dir = os.path.join(self._workon_home, source)
        target_dir = os.path.join(self._workon_home, target)

        if not os.path.isdir(source_dir):
            logger.error('%s does not exist.' % source_dir)
            sys.exit(1)

        if os.path.isdir(target_dir):
            logger.error('Can not overwrite %s.' % target_dir)
            sys.exit(1)

        logger.info("Cloning `%s` environment into `%s` on %s" % (source, target, self._workon_home))

        # Copies source to target
        cmd = [self._py, self._venv_clone, source_dir, target_dir]
        s = Subprocess()
        s.call(cmd)
开发者ID:Annia,项目名称:pythonbrew,代码行数:29,代码来源:venv.py

示例5: configure

 def configure(self):
     s = Subprocess(log=self.logfile, cwd=self.build_dir, verbose=self.options.verbose)
     cmd = "./configure --prefix=%s %s %s" % (
         self.install_dir,
         self.options.configure,
         " ".join(self.configure_options),
     )
     if self.options.verbose:
         logger.log(cmd)
     s.check_call(cmd)
开发者ID:steakknife,项目名称:pythonbrew,代码行数:10,代码来源:pythoninstaller.py

示例6: patch

 def patch(self):
     version = self.pkg.version
     try:
         s = Subprocess(log=self.logfile, cwd=self.build_dir)
         patches = []
         eds = {}
         if is_python24(version):
             patch_dir = PATH_PATCHES_MACOSX_PYTHON24
             patches = ['patch-configure', 'patch-Makefile.pre.in',
                        'patch-Lib-cgi.py.diff', 'patch-Lib-site.py.diff',
                        'patch-setup.py.diff', 'patch-Include-pyport.h',
                        'patch-Mac-OSX-Makefile.in', 'patch-Mac-OSX-IDLE-Makefile.in',
                        'patch-Mac-OSX-PythonLauncher-Makefile.in', 'patch-configure-badcflags.diff',
                        'patch-configure-arch_only.diff', 'patch-macosmodule.diff',
                        'patch-mactoolboxglue.diff', 'patch-pymactoolbox.diff',
                        'patch-gestaltmodule.c.diff']
         elif is_python25(version):
             patch_dir = PATH_PATCHES_MACOSX_PYTHON25
             patches = ['patch-Makefile.pre.in.diff', 
                        'patch-Lib-cgi.py.diff',
                        'patch-Lib-distutils-dist.py.diff', 
                        'patch-setup.py.diff',
                        'patch-configure-badcflags.diff', 
                        'patch-configure-arch_only.diff',
                        'patch-64bit.diff', 
                        'patch-pyconfig.h.in.diff',
                        'patch-gestaltmodule.c.diff']
             eds = {'_localemodule.c.ed': 'Modules/_localemodule.c', 
                    'locale.py.ed': 'Lib/locale.py'}
         elif is_python26(version):
             patch_dir = PATH_PATCHES_MACOSX_PYTHON26
             patches = ['patch-Lib-cgi.py.diff', 
                        'patch-Lib-distutils-dist.py.diff',
                        'patch-Mac-IDLE-Makefile.in.diff',
                        'patch-Mac-Makefile.in.diff',
                        'patch-Mac-PythonLauncher-Makefile.in.diff',
                        'patch-Mac-Tools-Doc-setup.py.diff',
                        'patch-setup.py-db46.diff',
                        'patch-Lib-ctypes-macholib-dyld.py.diff',
                        'patch-setup_no_tkinter.py.diff']
             eds = {'_localemodule.c.ed': 'Modules/_localemodule.c', 
                    'locale.py.ed': 'Lib/locale.py'}
             
         if patches or eds:
             logger.info("Patching %s" % self.pkg.name)
             for patch in patches:
                 s.check_call("patch -p0 < %s" % os.path.join(patch_dir, patch))
             for (ed, source) in eds.items():
                 ed = os.path.join(patch_dir, ed)
                 s.check_call('ed - %s < %s' % (source, ed))
     except:
         logger.error("Failed to patch `%s`" % self.build_dir)
         sys.exit(1)
开发者ID:npinto,项目名称:pythonbrew,代码行数:53,代码来源:pythoninstaller.py

示例7: configure

 def configure(self):
     configure_option = ""
     if is_macosx_snowleopard():
         version = self.pkg.version
         if is_python24(version):
             configure_option = '--with-universal-archs="intel" MACOSX_DEPLOYMENT_TARGET=10.6 CPPFLAGS="-D__DARWIN_UNIX03"'
         elif is_python25(version):
             configure_option = '--with-universal-archs="intel" MACOSX_DEPLOYMENT_TARGET=10.6 CPPFLAGS="-D_DARWIN_C_SOURCE"'
         elif is_python26(version):
             configure_option = '--with-universal-archs="intel" MACOSX_DEPLOYMENT_TARGET=10.6'
     
     s = Subprocess(log=self.logfile, cwd=self.build_dir)
     s.check_call("./configure --prefix=%s %s %s" % (self.install_dir, self.options.configure, configure_option))
开发者ID:nvie,项目名称:pythonbrew,代码行数:13,代码来源:installer.py

示例8: _do_patch

 def _do_patch(self):
     try:
         s = Subprocess(log=self.logfile, cwd=self.build_dir, verbose=self.options.verbose)
         if self.patches:
             logger.info("Patching %s" % self.pkg.name)
             for patch in self.patches:
                 if type(patch) is dict:
                     for (ed, source) in patch.items():
                         s.shell('ed - %s < %s' % (source, ed))
                 else:
                     s.shell("patch -p0 < %s" % patch)
     except:
         logger.error("Failed to patch `%s`.\n%s" % (self.build_dir, sys.exc_info()[1]))
         sys.exit(1)
开发者ID:Ank1tAggarwal,项目名称:pythonbrew,代码行数:14,代码来源:pythoninstaller.py

示例9: _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

示例10: make

 def make(self):
     s = Subprocess(log=self.logfile, cwd=self.build_dir)
     if self.options.force:
         s.check_call("make")
     else:
         s.check_call("make")
         s.check_call("make test")
开发者ID:nvie,项目名称:pythonbrew,代码行数:7,代码来源:installer.py

示例11: _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

示例12: run_command_create

    def run_command_create(self, options, args):
        if not os.access(PATH_VENVS, os.W_OK):
            logger.error("Can not create a virtual environment in %s.\nPermission denied." % PATH_VENVS)
            sys.exit(1)

        virtualenv_options = []
        if options.no_site_packages:
            virtualenv_options.append('--no-site-packages')
        
        for arg in args[1:]:
            target_dir = os.path.join(self._workon_home, arg)
            logger.info("Creating `%s` environment into %s" % (arg, self._workon_home))
            # make command
            cmd = [self._py, self._venv, '-p', self._target_py]
            cmd.extend(virtualenv_options)
            cmd.append(target_dir)
            # create environment
            s = Subprocess(verbose=True)
            s.call(cmd)
开发者ID:ampledata,项目名称:pythonbrew,代码行数:19,代码来源:venv.py

示例13: make

 def make(self):
     jobs = self.options.jobs
     make = ((jobs > 0 and 'make -j%s' % jobs) or 'make')
     s = Subprocess(log=self.logfile, cwd=self.build_dir)
     if self.options.force:
         s.check_call(make)
     else:
         s.check_call(make)
         s.check_call("make test")
开发者ID:npinto,项目名称:pythonbrew,代码行数:9,代码来源:pythoninstaller.py

示例14: make

 def make(self):
     jobs = self.options.jobs
     make = ((jobs > 0 and 'make -j%s' % jobs) or 'make')
     s = Subprocess(log=self.logfile, cwd=self.build_dir, verbose=self.options.verbose)
     s.check_call(make)
     if not self.options.no_test:
         if self.options.force:
             # note: ignore tests failure error.
             s.call("make test")
         else:
             s.check_call("make test")
开发者ID:Ank1tAggarwal,项目名称:pythonbrew,代码行数:11,代码来源:pythoninstaller.py

示例15: make_install

 def make_install(self):
     version = Version(self.pkg.version)
     if version == "1.5.2" or version == "1.6.1":
         makedirs(self.install_dir)
     s = Subprocess(log=self.logfile, cwd=self.build_dir, verbose=self.options.verbose)
     s.check_call("make install")
开发者ID:Ank1tAggarwal,项目名称:pythonbrew,代码行数:6,代码来源:pythoninstaller.py


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