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


Python logger.error函数代码示例

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


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

示例1: install

    def install(self):
        # check if java is installed
        r = subprocess.call("command -v java > /dev/null", shell=True)
        if r != 0:
            logger.error("Jython requires Java to be installed, but the 'java' command was not found in the path.")
            return

        # get content type.
        if is_file(self.download_url):
            path = fileurl_to_path(self.download_url)
            self.content_type = mimetypes.guess_type(path)[0]
        else:
            try:
                headerinfo = Downloader.read_head_info(self.download_url)
            except DownloadError:
                self.content_type = None
            else:
                self.content_type = headerinfo['content-type']
        if is_html(self.content_type):
            # note: maybe got 404 or 503 http status code.
            logger.error("Invalid content-type: `%s`" % self.content_type)
            return

        self.download()
        logger.info("\nThis could take a while. You can run the following command on another shell to track the status:")
        logger.info("  tail -f %s\n" % self.logfile)
        logger.info("Installing %s into %s" % (self.pkg.name, self.install_dir))
        cmd = 'java -jar %s -s -d %s' % (self.download_file, self.install_dir)
        s = Subprocess(log=self.logfile, verbose=self.options.verbose)
        s.check_call(cmd)
        self.symlink()
        logger.info("\nInstalled %(pkgname)s successfully." % {"pkgname": self.pkg.name})
开发者ID:simudream,项目名称:pythonz,代码行数:32,代码来源:pythoninstaller.py

示例2: __init__

    def __init__(self, version, options):
        # create directories
        makedirs(PATH_DISTS)
        makedirs(PATH_LOG)

        if options.file is not None:
            if not (is_archive_file(options.file) and os.path.isfile(options.file)):
                logger.error('invalid file specified: %s' % options.file)
                raise RuntimeError
            self.download_url = path_to_fileurl(options.file)
        elif options.url is not None:
            if not is_url(options.url):
                logger.error('invalid URL specified: %s' % options.url)
                raise RuntimeError
            self.download_url = options.url
        else:
            if version not in self.supported_versions:
                logger.warning("Unsupported Python version: `%s`, trying with the following URL anyway: %s" % (version, self.get_version_url(version)))
            self.download_url = self.get_version_url(version)
        self.pkg = Package(version, options.type)
        self.install_dir = os.path.join(PATH_PYTHONS, self.pkg.name)
        self.build_dir = os.path.join(PATH_BUILD, self.pkg.name)
        filename = Link(self.download_url).filename
        self.download_file = os.path.join(PATH_DISTS, filename)

        self.options = options
        self.logfile = os.path.join(PATH_LOG, 'build.log')
        self.patches = []
        self.configure_options = []
开发者ID:gthb,项目名称:pythonz,代码行数:29,代码来源:pythoninstaller.py

示例3: _update_pythonz

 def _update_pythonz(self, options, args):
     download_url = PYTHONZ_UPDATE_URL
     headinfo = get_headerinfo_from_url(download_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)
     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,'pythonz_install.py'), '--upgrade'])
     except:
         logger.error("Failed to update pythonz.")
         sys.exit(1)
     logger.info("The pythonz has been updated.")
开发者ID:Epictetus,项目名称:pythonz,代码行数:29,代码来源:update.py

示例4: install

    def install(self):
        # get content type.
        if is_file(self.download_url):
            path = fileurl_to_path(self.download_url)
            self.content_type = mimetypes.guess_type(path)[0]
        else:
            headerinfo = Downloader.read_head_info(self.download_url)
            self.content_type = headerinfo['content-type']
        if is_html(self.content_type):
            # note: maybe got 404 or 503 http status code.
            logger.error("Invalid content-type: `%s`" % self.content_type)
            return

        if os.path.isdir(self.install_dir):
            logger.info("You have already installed `%s`" % self.pkg.name)
            return

        self.download_and_extract()
        logger.info("\nThis could take a while. You can run the following command on another shell to track the status:")
        logger.info("  tail -f %s\n" % self.logfile)
        logger.info("Installing %s into %s" % (self.pkg.name, self.install_dir))
        try:
            self.patch()
            self.configure()
            self.make()
            self.make_install()
        except Exception:
            import traceback
            traceback.print_exc()
            rm_r(self.install_dir)
            logger.error("Failed to install %s. Check %s to see why." % (self.pkg.name, self.logfile))
            sys.exit(1)
        self.symlink()
        logger.info("\nInstalled %(pkgname)s successfully." % {"pkgname": self.pkg.name})
开发者ID:totakke,项目名称:pythonz,代码行数:34,代码来源:pythoninstaller.py

示例5: install

    def install(self):
        # cleanup
        if os.path.isdir(self.build_dir):
            shutil.rmtree(self.build_dir)

        # get content type.
        if is_file(self.download_url):
            path = fileurl_to_path(self.download_url)
            self.content_type = mimetypes.guess_type(path)[0]
        else:
            headerinfo = Downloader.read_head_info(self.download_url)
            self.content_type = headerinfo['content-type']
        if is_html(self.content_type):
            # note: maybe got 404 or 503 http status code.
            logger.error("Invalid content-type: `%s`" % self.content_type)
            return

        if os.path.isdir(self.install_dir):
            logger.info("You have already installed `%s`" % self.pkg.name)
            return

        self.download_and_extract()
        logger.info("\nThis could take a while. You can run the following command on another shell to track the status:")
        logger.info("  tail -f %s\n" % self.logfile)
        logger.info("Installing %s into %s" % (self.pkg.name, self.install_dir))
        shutil.copytree(self.build_dir, self.install_dir)
        self.symlink()
        logger.info("\nInstalled %(pkgname)s successfully." % {"pkgname": self.pkg.name})
开发者ID:gthb,项目名称:pythonz,代码行数:28,代码来源:pythoninstaller.py

示例6: run_command

    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,代码行数:32,代码来源:update.py

示例7: __init__

    def __init__(self, version, options):
        super(CPythonInstaller, self).__init__(version, options)

        if Version(self.pkg.version) >= '3.1':
            self.configure_options.append('--with-computed-gotos')

        if sys.platform == "darwin":
            # 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.shared:
                logger.error("Can't specify both framework and shared.")
                raise Exception
            if options.framework:
                self.configure_options.append('--enable-framework=%s' % os.path.join(self.install_dir, 'Frameworks'))
            if options.shared:
                self.configure_options.append('--enable-shared')
            if options.universal:
                self.configure_options.append('--enable-universalsdk=/')
                self.configure_options.append('--with-universal-archs=intel')
        else:
            if options.shared:
                self.configure_options.append('--enable-shared')
开发者ID:totakke,项目名称:pythonz,代码行数:26,代码来源:pythoninstaller.py

示例8: extract_downloadfile

def extract_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:msabramo,项目名称:pythonz,代码行数:8,代码来源:util.py

示例9: run_command

    def run_command(self, options, args):
        if not args or len(args) > 1:
            self.parser.print_help()
            return

        pkg = Package(args[0], options.type)
        pkgname = pkg.name
        if not is_installed(pkg):
            logger.error("`%s` is not installed." % pkgname)
            return
        logger.log(os.path.join(PATH_PYTHONS, pkgname, 'bin', 'python'))
开发者ID:Eyepea,项目名称:pythonz,代码行数:11,代码来源:locate.py

示例10: download

 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,代码行数:11,代码来源:pythoninstaller.py

示例11: 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:msabramo,项目名称:pythonz,代码行数:53,代码来源:util.py

示例12: _apply_patches

 def _apply_patches(self):
     try:
         s = Subprocess(log=self.logfile, cwd=self.build_dir, verbose=self.options.verbose)
         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:totakke,项目名称:pythonz,代码行数:12,代码来源:pythoninstaller.py

示例13: run_command

 def run_command(self, options, args):
     if args:
         # Uninstall pythons
         for arg in args:
             pkg = Package(arg, options.type)
             pkgname = pkg.name
             if not is_installed(pkg):
                 logger.error("`%s` is not installed." % pkgname)
                 continue
             rm_r(os.path.join(PATH_PYTHONS, pkgname))
     else:
         self.parser.print_help()
开发者ID:EvertonSilva,项目名称:pythonz,代码行数:12,代码来源:uninstall.py

示例14: __init__

    def __init__(self, version, options):
        # create directories
        makedirs(PATH_BUILD)
        makedirs(PATH_DISTS)
        makedirs(PATH_LOG)

        if options.file is not None:
            if not (is_archive_file(options.file) and os.path.isfile(options.file)):
                logger.error('invalid file specified: %s' % options.file)
                raise RuntimeError
            self.download_url = path_to_fileurl(options.file)
        elif options.url is not None:
            if not is_url(options.url):
                logger.error('invalid URL specified: %s' % options.url)
                raise RuntimeError
            self.download_url = options.url
        else:
            self.download_url = self.get_version_url(version)
            if version not in self.supported_versions:
                logger.warning("Unsupported Python version: `%s`, trying with the following URL anyway: %s" % (version, self.download_url))

        self.pkg = Package(version, options.type)
        if options.external_path:
            if not os.path.isabs(options.external_path):
                options.external_path = os.path.join(
                    os.path.abspath(os.path.curdir),
                    options.external_path)
            self.install_dir = os.path.join(options.external_path,
                                            self.pkg.name)
        else:
            self.install_dir = os.path.join(PATH_PYTHONS, self.pkg.name)
        self.build_dir = os.path.join(PATH_BUILD, self.pkg.name)
        filename = Link(self.download_url).filename
        self.download_file = os.path.join(PATH_DISTS, filename)

        # cleanup
        if os.path.isdir(self.build_dir):
            shutil.rmtree(self.build_dir)

        if os.path.isdir(self.install_dir):
            if options.reinstall:
                shutil.rmtree(self.install_dir)
            else:
                raise AlreadyInstalledError("You have already installed `%s`" % self.pkg.name)

        self.options = options
        self.logfile = os.path.join(PATH_LOG, 'build.log')
        self.patches = []
        self.configure_options = []
开发者ID:simudream,项目名称:pythonz,代码行数:49,代码来源:pythoninstaller.py

示例15: download

 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,代码行数:15,代码来源:pythoninstaller.py


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