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


Python logger.error函数代码示例

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


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

示例1: run_command

    def run_command(self, options, args):
        if not args:
            self.parser.print_help()
            sys.exit(1)
        cmd = args[0]
        if not cmd in ('init', 'create', 'delete', 'use', 'list', 'clone', 'rename', 'print_activate'):
            self.parser.print_help()
            sys.exit(1)

        # initialize?
        if cmd == 'init':
            self.run_command_init()
            return

        # target python interpreter
        if options.python:
            pkgname = Package(options.python).name
            if not is_installed(pkgname):
                logger.error('%s is not installed.' % pkgname)
                sys.exit(1)
        else:
            pkgname = get_using_python_pkgname()

        self._pkgname = pkgname
        if self._pkgname:
            self._target_py = os.path.join(PATH_PYTHONS, pkgname, 'bin', 'python')
            self._workon_home = os.path.join(PATH_VENVS, pkgname)
            self._py = os.path.join(PATH_PYTHONS, pkgname, 'bin', 'python')

        # is already installed virtualenv?
        if not os.path.exists(self._venv) or not os.path.exists(self._venv_clone):
            self.run_command_init()

        # Create a shell script
        self.__getattribute__('run_command_%s' % cmd)(options, args)
开发者ID:Annia,项目名称:pythonbrew,代码行数:35,代码来源:venv.py

示例2: __init__

    def __init__(self, arg, options):
        super(PythonInstallerMacOSX, self).__init__(arg, options)

        # check for version
        version = Version(self.pkg.version)
        if version < '2.6' and (version != '2.4.6' and version < '2.5.5'):
            logger.error("`%s` is not supported on MacOSX Snow Leopard" % self.pkg.name)
            raise NotSupportedVersionException
        # set configure options
        target = get_macosx_deployment_target()
        if target:
            self.configure_options.append('MACOSX_DEPLOYMENT_TARGET=%s' % target)

        # set build options
        if options.framework and options.static:
            logger.error("Can't specify both framework and static.")
            raise Exception
        if options.framework:
            self.configure_options.append('--enable-framework=%s' % os.path.join(self.install_dir, 'Frameworks'))
        elif not options.static:
            self.configure_options.append('--enable-shared')
        if options.universal:
            self.configure_options.append('--enable-universalsdk=/')
            self.configure_options.append('--with-universal-archs=intel')

        # note: skip `make test` to avoid hanging test_threading.
        if is_python25(version) or is_python24(version):
            self.options.no_test = True
开发者ID:Ank1tAggarwal,项目名称:pythonbrew,代码行数:28,代码来源:pythoninstaller.py

示例3: run_command

 def run_command(self, options, args):
     if args:
         # Uninstall pythonidae
         for arg in args:
             pkg = Package(arg)
             pkgname = pkg.name
             pkgpath = os.path.join(PATH_PYTHONS, pkgname)
             venvpath = os.path.join(PATH_VENVS, pkgname)
             if not is_installed(pkgname):
                 logger.error("`%s` is not installed." % pkgname)
                 continue
             if get_using_python_pkgname() == pkgname:
                 off()
             for d in os.listdir(PATH_BIN):
                 # remove symlink
                 path = os.path.join(PATH_BIN, d)
                 if os.path.islink(path):
                     basename = os.path.basename(os.path.realpath(path))
                     tgtpath = os.path.join(pkgpath, "bin", basename)
                     if os.path.isfile(tgtpath) and os.path.samefile(path, tgtpath):
                         unlink(path)
             rm_r(pkgpath)
             rm_r(venvpath)
     else:
         self.parser.print_help()
开发者ID:ovoxo,项目名称:pythonbrew,代码行数:25,代码来源:uninstall.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: 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

示例6: 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

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

示例8: copy_libs

def copy_libs(source, target):
    """Copies every lib inside source's site-packages folder into 
    target's site-packages without replacing already existing libs.
    source and target are the names of the venvs""" 
    
    # File to copy never-the-less (to add libs to the PATH)
    easy_inst = "easy-install.pth"
    
    pkgname = get_using_python_pkgname()
    if not pkgname:
        logger.error('Can not use venv command before switching a python.  Try \'pythonbrew switch <version of python>\'.')
        sys.exit(1)
        
    source_path = glob.glob(os.path.join(PATH_VENVS, pkgname) + "/" + source + "/lib/python*/site-packages/")[0]
    target_path = glob.glob(os.path.join(PATH_VENVS, pkgname) + "/" + target + "/lib/python*/site-packages/")[0]
        
    path, dirs, files = os.walk(source_path).next()
    for curr_dir in dirs:
        if not os.path.exists(target_path + curr_dir):
            shutil.copytree(source_path+curr_dir, target_path+curr_dir)
        
    for curr_file in files:
        if not os.path.exists(target_path + curr_file):
            shutil.copyfile(source_path+curr_file, target_path+curr_file)
        elif curr_file == easy_inst:
            os.remove(target_path+curr_file)
            shutil.copyfile(source_path+curr_file, target_path+curr_file)
开发者ID:jmagnusson,项目名称:pythonbrew,代码行数:27,代码来源:util.py

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

示例10: run_command_use

    def run_command_use(self, options, args):
        if len(args) < 2:
            logger.error("Unrecognized command line argument: ( 'pythonbrew venv use <project>' )")
            sys.exit(1)

        workon_home = None
        activate = None
        if self._pkgname:
            workon_home = self._workon_home
            activate = os.path.join(workon_home, args[1], 'bin', 'activate')
        else:
            for pkgname in get_installed_pythons_pkgname():
                workon_home = os.path.join(PATH_VENVS, pkgname)
                if os.path.isdir(workon_home):
                    if len([d for d in os.listdir(workon_home) if d == args[1]]) > 0:
                        activate = os.path.join(workon_home, args[1], 'bin', 'activate')
                        break
        if not activate or not os.path.exists(activate):
            logger.error('`%s` environment does not exist. Try `pythonbrew venv create %s`.' % (args[1], args[1]))
            sys.exit(1)

        self._write("""\
echo '# Using `%(arg)s` environment (found in %(workon_home)s)'
echo '# To leave an environment, simply run `deactivate`'
source '%(activate)s'
""" % {'arg': args[1], 'workon_home': workon_home, 'activate': activate})
开发者ID:Annia,项目名称:pythonbrew,代码行数:26,代码来源:venv.py

示例11: install

 def install(self):
     if os.path.isdir(self.install_dir):
         logger.info("You are already installed `%s`" % self.pkg.name)
         sys.exit()
     self.ensure()
     self.download()
     logger.info("")
     logger.info("This could take a while. You can run the following command on another shell to track the status:")
     logger.info("  tail -f %s" % self.logfile)
     logger.info("")
     self.unpack()
     self.patch()
     logger.info("Installing %s into %s" % (self.pkg.name, self.install_dir))
     try:
         self.configure()
         self.make()
         self.make_install()
     except:
         rm_r(self.install_dir)
         logger.error("Failed to install %s. See %s to see why." % (self.pkg.name, self.logfile))
         logger.info("  pythonbrew install --force %s" % self.pkg.version)
         sys.exit(1)
     self.install_setuptools()
     logger.info("Installed %(pkgname)s successfully. Run the following command to switch to %(pkgname)s."
                 % {"pkgname":self.pkg.name})
     logger.info("")
     logger.info("  pythonbrew switch %s" % self.pkg.version)
开发者ID:nvie,项目名称:pythonbrew,代码行数:27,代码来源:installer.py

示例12: unpack_downloadfile

def unpack_downloadfile(content_type, download_file, target_dir):
    logger.info("Extracting %s into %s" % (os.path.basename(download_file), target_dir))
    if is_gzip(content_type, download_file):
        untar_file(download_file, target_dir)
    else:
        logger.error("Cannot determine archive format of %s" % download_file)
        return False
    return True
开发者ID:npinto,项目名称:pythonbrew,代码行数:8,代码来源:util.py

示例13: _symlink_venv

 def _symlink_venv(self, srcbin, dstbin, venv_dir):
     """Create a symlink.
     """
     src = os.path.join(venv_dir, 'bin', srcbin)
     dst = os.path.join(PATH_BIN, dstbin)
     if os.path.isfile(src):
         symlink(src, dst)
     else:
         logger.error("%s was not found in your path." % src)
开发者ID:LTD-Beget,项目名称:pythonbrew,代码行数:9,代码来源:symlink.py

示例14: _symlink

 def _symlink(self, srcbin, dstbin, pkgname):
     """Create a symlink.
     """
     src = os.path.join(PATH_PYTHONS, pkgname, 'bin', srcbin)
     dst = os.path.join(PATH_BIN, dstbin)
     if os.path.isfile(src):
         symlink(src, dst)
     else:
         logger.error("%s was not found in your path." % src)
开发者ID:Ank1tAggarwal,项目名称:pythonbrew,代码行数:9,代码来源:symlink.py

示例15: run_command_print_activate

 def run_command_print_activate(self, options, args):
     if len(args) < 2:
         logger.error("Unrecognized command line argument: ( 'pythonbrew venv print_activate <project>' )")
         sys.exit(1)
     
     activate = os.path.join(self._workon_home, args[1], 'bin', 'activate')
     if not os.path.exists(activate):
         logger.error('`%s` environment already does not exist. Try `pythonbrew venv create %s`.' % (args[1], args[1]))
         sys.exit(1)
         
     logger.log(activate)
开发者ID:ampledata,项目名称:pythonbrew,代码行数:11,代码来源:venv.py


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