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

Python logger.error函数代码示例

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

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



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


示例16: untar_file

def untar_file(filename, location):
    if not os.path.exists(location):
        os.makedirs(location)
    if filename.lower().endswith('.gz') or filename.lower().endswith('.tgz'):
        mode = 'r:gz'
    elif filename.lower().endswith('.bz2') or filename.lower().endswith('.tbz'):
        mode = 'r:bz2'
    elif filename.lower().endswith('.tar'):
        mode = 'r'
    else:
        logger.error('Cannot determine compression type for file %s' % filename)
        mode = 'r:*'
    tar = tarfile.open(filename, mode)
    try:
        # note: python<=2.5 doesnt seem to know about pax headers, filter them
        leading = has_leading_dir([
            member.name for member in tar.getmembers()
            if member.name != 'pax_global_header'
        ])
        for member in tar.getmembers():
            fn = member.name
            if fn == 'pax_global_header':
                continue
            if leading:
                fn = split_leading_dir(fn)[1]
            path = os.path.join(location, fn)
            if member.isdir():
                if not os.path.exists(path):
                    os.makedirs(path)
            else:
                try:
                    fp = tar.extractfile(member)
                except (KeyError, AttributeError):
                    e = sys.exc_info()[1]
                    # Some corrupt tar files seem to produce this
                    # (specifically bad symlinks)
                    logger.error('In the tar file %s the member %s is invalid: %s'
                                  % (filename, member.name, e))
                    continue
                if not os.path.exists(os.path.dirname(path)):
                    os.makedirs(os.path.dirname(path))
                destfp = open(path, 'wb')
                try:
                    shutil.copyfileobj(fp, destfp)
                finally:
                    destfp.close()
                fp.close()
                # note: configure ...etc
                os.chmod(path, member.mode)
                # note: the file timestamps should be such that asdl_c.py is not invoked.
                os.utime(path, (member.mtime, member.mtime))
    finally:
        tar.close()
开发者ID:limeyd,项目名称:pythonbrew,代码行数:53,代码来源:util.py


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


示例18: run_command_delete

 def run_command_delete(self, options, args):
     for arg in args[1:]:
         target_dir = os.path.join(self._workon_home, arg)
         if not os.path.isdir(target_dir):
             logger.error('%s already does not exist.' % target_dir)
         else:
             if not os.access(target_dir, os.W_OK):
                 logger.error("Can not delete %s.\nPermission denied." % target_dir)
                 continue
             logger.info('Deleting `%s` environment in %s' % (arg, self._workon_home))
             # make command
             rm_r(target_dir)
开发者ID:ampledata,项目名称:pythonbrew,代码行数:12,代码来源:venv.py


示例19: run_command

 def run_command(self, options, args):
     if not args:
         logger.error("Unrecognized command line argument: argument not found.")
         sys.exit(1)
     pkg = Package(args[0])
     pkgname = pkg.name
     pkgdir = "%s/%s" % (PATH_PYTHONS, pkgname)
     if not os.path.isdir(pkgdir):
         logger.error("`%s` is not installed." % pkgname)
         sys.exit(1)
     self._switch_dir(pkgdir)
     logger.info("Switched to %s" % pkgname)
开发者ID:nvie,项目名称:pythonbrew,代码行数:12,代码来源:switch.py


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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python logger.info函数代码示例发布时间:2022-05-27
下一篇:
Python downloader.Downloader类代码示例发布时间: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