Python distutils.log 模块,error() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用distutils.log.error()

项目:exatomic    作者:exa-analytics    | 项目源码 | 文件源码
def run(self):
        if not self.has_npm():
            log.error("`npm` unavailable.  If you're running this command using sudo, make sure `npm` is available to sudo")
        else:
            env = os.environ.copy()
            env['PATH'] = npm_path
            log.info("Installing build dependencies with npm. This may take a while...")
            check_call(["npm", "install"], cwd=jsroot, stdout=sys.stdout, stderr=sys.stderr, **prckws)
            os.utime(node_modules, None)

        for t in self.targets:
            if not os.path.exists(t):
                msg = "Missing file: %s" % t
                if not self.has_npm():
                    msg += "\nnpm is required to build a development version of jupyter-" + name
                raise ValueError(msg)

        # update package data in case this created new files
        update_package_data(self.distribution)
项目:notebook-molecular-visualization    作者:Autodesk    | 项目源码 | 文件源码
def js_prerelease(command, strict=False):
    """decorator for building minified js/css prior to another command"""
    class DecoratedCommand(command):
        def run(self):
            jsdeps = self.distribution.get_command_obj('jsdeps')
            if not is_repo and all(os.path.exists(t) for t in jsdeps.targets):
                # sdist, nothing to do
                command.run(self)
                return

            try:
                self.distribution.run_command('jsdeps')
            except Exception as e:
                missing = [t for t in jsdeps.targets if not os.path.exists(t)]
                if strict or missing:
                    log.warn('rebuilding js and css failed')
                    if missing:
                        log.error('missing files: %s' % missing)
                    raise e
                else:
                    log.warn('rebuilding js and css failed (not a problem)')
                    log.warn(str(e))
            command.run(self)
            update_package_data(self.distribution)
    return DecoratedCommand
项目:geonotebook    作者:OpenGeoscience    | 项目源码 | 文件源码
def js_prerelease(command, strict=False):
    """Decorator for building minified js/css prior to another command."""
    class DecoratedCommand(command):
        def run(self):
            jsdeps = self.distribution.get_command_obj('jsdeps')
            if not is_repo and all(os.path.exists(t) for t in jsdeps.targets):
                # sdist, nothing to do
                command.run(self)
                return

            try:
                self.distribution.run_command('jsdeps')
            except Exception as e:
                missing = [t for t in jsdeps.targets if not os.path.exists(t)]
                if strict or missing:
                    log.warn('rebuilding js and css failed')
                    if missing:
                        log.error('missing files: %s' % missing)
                    raise e
                else:
                    log.warn('rebuilding js and css failed (not a problem)')
                    log.warn(str(e))
            command.run(self)
            update_package_data(self.distribution)
    return DecoratedCommand
项目:widget-cookiecutter    作者:jupyter-widgets    | 项目源码 | 文件源码
def js_prerelease(command, strict=False):
    """decorator for building minified js/css prior to another command"""
    class DecoratedCommand(command):
        def run(self):
            jsdeps = self.distribution.get_command_obj('jsdeps')
            if not is_repo and all(os.path.exists(t) for t in jsdeps.targets):
                # sdist, nothing to do
                command.run(self)
                return

            try:
                self.distribution.run_command('jsdeps')
            except Exception as e:
                missing = [t for t in jsdeps.targets if not os.path.exists(t)]
                if strict or missing:
                    log.warn('rebuilding js and css failed')
                    if missing:
                        log.error('missing files: %s' % missing)
                    raise e
                else:
                    log.warn('rebuilding js and css failed (not a problem)')
                    log.warn(str(e))
            command.run(self)
            update_package_data(self.distribution)
    return DecoratedCommand
项目:widget-cookiecutter    作者:jupyter-widgets    | 项目源码 | 文件源码
def run(self):
        has_npm = self.has_npm()
        if not has_npm:
            log.error("`npm` unavailable.  If you're running this command using sudo, make sure `npm` is available to sudo")

        env = os.environ.copy()
        env['PATH'] = npm_path

        if self.should_run_npm_install():
            log.info("Installing build dependencies with npm.  This may take a while...")
            npmName = self.get_npm_name();
            check_call([npmName, 'install'], cwd=node_root, stdout=sys.stdout, stderr=sys.stderr)
            os.utime(self.node_modules, None)

        for t in self.targets:
            if not os.path.exists(t):
                msg = 'Missing file: %s' % t
                if not has_npm:
                    msg += '\nnpm is required to build a development version of a widget extension'
                raise ValueError(msg)

        # update package data in case this created new files
        update_package_data(self.distribution)
项目:ipysankeywidget    作者:ricklupton    | 项目源码 | 文件源码
def js_prerelease(command, strict=False):
    """decorator for building minified js/css prior to another command"""
    class DecoratedCommand(command):
        def run(self):
            jsdeps = self.distribution.get_command_obj('jsdeps')
            if not is_repo and all(os.path.exists(t) for t in jsdeps.targets):
                # sdist, nothing to do
                command.run(self)
                return

            try:
                self.distribution.run_command('jsdeps')
            except Exception as e:
                missing = [t for t in jsdeps.targets if not os.path.exists(t)]
                if strict or missing:
                    log.warn('rebuilding js and css failed')
                    if missing:
                        log.error('missing files: %s' % missing)
                    raise e
                else:
                    log.warn('rebuilding js and css failed (not a problem)')
                    log.warn(str(e))
            command.run(self)
            update_package_data(self.distribution)
    return DecoratedCommand
项目:ipysankeywidget    作者:ricklupton    | 项目源码 | 文件源码
def run(self):
        has_npm = self.has_npm()
        if not has_npm:
            log.error("`npm` unavailable.  If you're running this command using sudo, make sure `npm` is available to sudo")

        env = os.environ.copy()
        env['PATH'] = npm_path

        if self.should_run_npm_install():
            log.info("Installing build dependencies with npm.  This may take a while...")
            npm_name = self.get_npm_name()
            check_call([npm_name, 'install'], cwd=node_root, stdout=sys.stdout, stderr=sys.stderr)
            os.utime(self.node_modules, None)

        for t in self.targets:
            if not os.path.exists(t):
                msg = 'Missing file: %s' % t
                if not has_npm:
                    msg += '\nnpm is required to build a development version of a widget extension'
                raise ValueError(msg)

        # update package data in case this created new files
        update_package_data(self.distribution)
项目:iprofiler    作者:j-towns    | 项目源码 | 文件源码
def js_prerelease(command, strict=False):
    """decorator for building minified js/css prior to another command"""
    class DecoratedCommand(command):
        def run(self):
            jsdeps = self.distribution.get_command_obj('jsdeps')
            if not is_repo and all(os.path.exists(t) for t in jsdeps.targets):
                # sdist, nothing to do
                command.run(self)
                return

            try:
                self.distribution.run_command('jsdeps')
            except Exception as e:
                missing = [t for t in jsdeps.targets if not os.path.exists(t)]
                if strict or missing:
                    log.warn('rebuilding js and css failed')
                    if missing:
                        log.error('missing files: %s' % missing)
                    raise e
                else:
                    log.warn('rebuilding js and css failed (not a problem)')
                    log.warn(str(e))
            command.run(self)
            update_package_data(self.distribution)
    return DecoratedCommand
项目:iprofiler    作者:j-towns    | 项目源码 | 文件源码
def run(self):
        has_npm = self.has_npm()
        if not has_npm:
            log.error("`npm` unavailable.  If you're running this command using sudo, make sure `npm` is available to sudo")

        env = os.environ.copy()
        env['PATH'] = npm_path

        if self.should_run_npm_install():
            log.info("Installing build dependencies with npm.  This may take a while...")
            check_call(['npm', 'install'], cwd=node_root, stdout=sys.stdout, stderr=sys.stderr)
            os.utime(self.node_modules, None)

        for t in self.targets:
            if not os.path.exists(t):
                msg = 'Missing file: %s' % t
                if not has_npm:
                    msg += '\nnpm is required to build a development version of widgetsnbextension'
                raise ValueError(msg)

        # update package data in case this created new files
        update_package_data(self.distribution)
项目:BigBrotherBot-For-UrT43    作者:ptitbigorneau    | 项目源码 | 文件源码
def get_version(self):
            """extract version number from the b3.egg-info/PKG-INFO file"""
            log.info(">>> parse B3 version")
            pkginfo_file = os.path.join(self.build_exe, 'PKG-INFO')
            pkginfo_version = re.compile(
                r'^\s*Version:\s*(?P<version>(?P<numbers>\d+\.\d+(?:\.\d+)?)(?P<pre_release>(?:a|b|dev|d)\d*)?(?P<suffix>.*?))\s*$',
                re.MULTILINE)
            with open(pkginfo_file, 'r') as f:
                match = pkginfo_version.search(f.read())
                if not match:
                    log.error("could not find version from %s" % pkginfo_file)
                    sys.exit(1)

            current_b3_version_part1 = match.group("numbers")
            current_b3_version_part2 = ""
            if match.group("pre_release"):
                current_b3_version_part2 += match.group("pre_release")
            if match.group("suffix"):
                current_b3_version_part2 += match.group("suffix")

            return current_b3_version_part1, current_b3_version_part2
项目:jupyter_britecharts_widget_tutorial    作者:kazuar    | 项目源码 | 文件源码
def js_prerelease(command, strict=False):
    """decorator for building minified js/css prior to another command"""
    class DecoratedCommand(command):
        def run(self):
            jsdeps = self.distribution.get_command_obj('jsdeps')
            if not is_repo and all(os.path.exists(t) for t in jsdeps.targets):
                # sdist, nothing to do
                command.run(self)
                return

            try:
                self.distribution.run_command('jsdeps')
            except Exception as e:
                missing = [t for t in jsdeps.targets if not os.path.exists(t)]
                if strict or missing:
                    log.warn('rebuilding js and css failed')
                    if missing:
                        log.error('missing files: %s' % missing)
                    raise e
                else:
                    log.warn('rebuilding js and css failed (not a problem)')
                    log.warn(str(e))
            command.run(self)
            update_package_data(self.distribution)
    return DecoratedCommand
项目:jupyter_britecharts_widget_tutorial    作者:kazuar    | 项目源码 | 文件源码
def run(self):
        has_npm = self.has_npm()
        if not has_npm:
            log.error("`npm` unavailable.  If you're running this command using sudo, make sure `npm` is available to sudo")

        env = os.environ.copy()
        env['PATH'] = npm_path

        if self.should_run_npm_install():
            log.info("Installing build dependencies with npm.  This may take a while...")
            check_call(['npm', 'install'], cwd=node_root, stdout=sys.stdout, stderr=sys.stderr)
            os.utime(self.node_modules, None)

        for t in self.targets:
            if not os.path.exists(t):
                msg = 'Missing file: %s' % t
                if not has_npm:
                    msg += '\nnpm is required to build a development version of widgetsnbextension'
                raise ValueError(msg)

        # update package data in case this created new files
        update_package_data(self.distribution)
项目:python-    作者:secondtonone1    | 项目源码 | 文件源码
def log_error(self, msg, *args, **kw):
        log.error(msg, *args)
项目:my-first-blog    作者:AnkurBegining    | 项目源码 | 文件源码
def log_error(self, msg, *args, **kw):
        log.error(msg, *args)
项目:Flask_Blog    作者:sugarguo    | 项目源码 | 文件源码
def log_error(self, msg, *args, **kw):
        log.error(msg, *args)
项目:swjtu-pyscraper    作者:Desgard    | 项目源码 | 文件源码
def log_error(self, msg, *args, **kw):
        log.error(msg, *args)
项目:noc-orchestrator    作者:DirceuSilvaLabs    | 项目源码 | 文件源码
def log_error(self, msg, *args, **kw):
        log.error(msg, *args)
项目:noc-orchestrator    作者:DirceuSilvaLabs    | 项目源码 | 文件源码
def log_error(self, msg, *args, **kw):
        log.error(msg, *args)
项目:noc-orchestrator    作者:DirceuSilvaLabs    | 项目源码 | 文件源码
def log_error(self, msg, *args, **kw):
        log.error(msg, *args)
项目:jira_worklog_scanner    作者:pgarneau    | 项目源码 | 文件源码
def log_error(self, msg, *args, **kw):
        log.error(msg, *args)
项目:zanph    作者:zanph    | 项目源码 | 文件源码
def log_error(self, msg, *args, **kw):
        log.error(msg, *args)
项目:Sci-Finder    作者:snverse    | 项目源码 | 文件源码
def log_error(self, msg, *args, **kw):
        log.error(msg, *args)
项目:Sci-Finder    作者:snverse    | 项目源码 | 文件源码
def log_error(self, msg, *args, **kw):
        log.error(msg, *args)
项目:devsecops-example-helloworld    作者:boozallen    | 项目源码 | 文件源码
def run_command_hooks(cmd_obj, hook_kind):
    """Run hooks registered for that command and phase.

    *cmd_obj* is a finalized command object; *hook_kind* is either
    'pre_hook' or 'post_hook'.
    """

    if hook_kind not in ('pre_hook', 'post_hook'):
        raise ValueError('invalid hook kind: %r' % hook_kind)

    hooks = getattr(cmd_obj, hook_kind, None)

    if hooks is None:
        return

    for hook in hooks.values():
        if isinstance(hook, str):
            try:
                hook_obj = resolve_name(hook)
            except ImportError:
                err = sys.exc_info()[1] # For py3k
                raise DistutilsModuleError('cannot find hook %s: %s' %
                                           (hook,err))
        else:
            hook_obj = hook

        if not hasattr(hook_obj, '__call__'):
            raise DistutilsOptionError('hook %r is not callable' % hook)

        log.info('running %s %s for command %s',
                 hook_kind, hook, cmd_obj.get_command_name())

        try :
            hook_obj(cmd_obj)
        except:
            e = sys.exc_info()[1]
            log.error('hook %s raised exception: %s\n' % (hook, e))
            log.error(traceback.format_exc())
            sys.exit(1)
项目:ascii-art-py    作者:blinglnav    | 项目源码 | 文件源码
def log_error(self, msg, *args, **kw):
        log.error(msg, *args)
项目:whoseline    作者:bmorris3    | 项目源码 | 文件源码
def parse_config(cls):
        if not os.path.exists('setup.cfg'):
            return {}

        cfg = ConfigParser()

        try:
            cfg.read('setup.cfg')
        except Exception as e:
            if DEBUG:
                raise

            log.error(
                "Error reading setup.cfg: {0!r}\n{1} will not be "
                "automatically bootstrapped and package installation may fail."
                "\n{2}".format(e, PACKAGE_NAME, _err_help_msg))
            return {}

        if not cfg.has_section('ah_bootstrap'):
            return {}

        config = {}

        for option, type_ in CFG_OPTIONS:
            if not cfg.has_option('ah_bootstrap', option):
                continue

            if type_ is bool:
                value = cfg.getboolean('ah_bootstrap', option)
            else:
                value = cfg.get('ah_bootstrap', option)

            config[option] = value

        return config
项目:dust_extinction    作者:karllark    | 项目源码 | 文件源码
def parse_config(cls):
        if not os.path.exists('setup.cfg'):
            return {}

        cfg = ConfigParser()

        try:
            cfg.read('setup.cfg')
        except Exception as e:
            if DEBUG:
                raise

            log.error(
                "Error reading setup.cfg: {0!r}\n{1} will not be "
                "automatically bootstrapped and package installation may fail."
                "\n{2}".format(e, PACKAGE_NAME, _err_help_msg))
            return {}

        if not cfg.has_section('ah_bootstrap'):
            return {}

        config = {}

        for option, type_ in CFG_OPTIONS:
            if not cfg.has_option('ah_bootstrap', option):
                continue

            if type_ is bool:
                value = cfg.getboolean('ah_bootstrap', option)
            else:
                value = cfg.get('ah_bootstrap', option)

            config[option] = value

        return config
项目:ivaochdoc    作者:ivaoch    | 项目源码 | 文件源码
def log_error(self, msg, *args, **kw):
        log.error(msg, *args)
项目:aws-cfn-plex    作者:lordmuffin    | 项目源码 | 文件源码
def log_error(self, msg, *args, **kw):
        log.error(msg, *args)
项目:RPoint    作者:george17-meet    | 项目源码 | 文件源码
def log_error(self, msg, *args, **kw):
        log.error(msg, *args)
项目:RPoint    作者:george17-meet    | 项目源码 | 文件源码
def run_command_hooks(cmd_obj, hook_kind):
    """Run hooks registered for that command and phase.

    *cmd_obj* is a finalized command object; *hook_kind* is either
    'pre_hook' or 'post_hook'.
    """

    if hook_kind not in ('pre_hook', 'post_hook'):
        raise ValueError('invalid hook kind: %r' % hook_kind)

    hooks = getattr(cmd_obj, hook_kind, None)

    if hooks is None:
        return

    for hook in hooks.values():
        if isinstance(hook, str):
            try:
                hook_obj = resolve_name(hook)
            except ImportError:
                err = sys.exc_info()[1] # For py3k
                raise errors.DistutilsModuleError('cannot find hook %s: %s' %
                                                  (hook,err))
        else:
            hook_obj = hook

        if not hasattr(hook_obj, '__call__'):
            raise errors.DistutilsOptionError('hook %r is not callable' % hook)

        log.info('running %s %s for command %s',
                 hook_kind, hook, cmd_obj.get_command_name())

        try :
            hook_obj(cmd_obj)
        except:
            e = sys.exc_info()[1]
            log.error('hook %s raised exception: %s\n' % (hook, e))
            log.error(traceback.format_exc())
            sys.exit(1)
项目:exatomic    作者:exa-analytics    | 项目源码 | 文件源码
def js_prerelease(command, strict=False):
    """Build minified JS/CSS prior to performing the command."""
    class DecoratedCommand(command):
        """
        Used by ``js_prerelease`` to modify JS/CSS prior to running the command.
        """
        def run(self):
            jsdeps = self.distribution.get_command_obj("jsdeps")
            if not os.path.exists(".git") and all(os.path.exists(t) for t in jsdeps.targets):
                command.run(self)
                return
            try:
                self.distribution.run_command("jsdeps")
            except Exception as e:
                missing = [t for t in jsdeps.targets if not os.path.exists(t)]
                if strict or missing:
                    log.warn("Rebuilding JS/CSS failed")
                    if missing:
                        log.error("Missing files: {}".format(missing))
                    raise e
                else:
                    log.warn("Rebuilding JS/CSS failed but continuing...")
                    log.warn(str(e))
            command.run(self)
            update_package_data(self.distribution)
    return DecoratedCommand
项目:thejoker    作者:adrn    | 项目源码 | 文件源码
def parse_config(cls):
        if not os.path.exists('setup.cfg'):
            return {}

        cfg = ConfigParser()

        try:
            cfg.read('setup.cfg')
        except Exception as e:
            if DEBUG:
                raise

            log.error(
                "Error reading setup.cfg: {0!r}\n{1} will not be "
                "automatically bootstrapped and package installation may fail."
                "\n{2}".format(e, PACKAGE_NAME, _err_help_msg))
            return {}

        if not cfg.has_section('ah_bootstrap'):
            return {}

        config = {}

        for option, type_ in CFG_OPTIONS:
            if not cfg.has_option('ah_bootstrap', option):
                continue

            if type_ is bool:
                value = cfg.getboolean('ah_bootstrap', option)
            else:
                value = cfg.get('ah_bootstrap', option)

            config[option] = value

        return config
项目:isni-reconcile    作者:cmh2166    | 项目源码 | 文件源码
def log_error(self, msg, *args, **kw):
        log.error(msg, *args)
项目:AshsSDK    作者:thehappydinoa    | 项目源码 | 文件源码
def log_error(self, msg, *args, **kw):
        log.error(msg, *args)
项目:habilitacion    作者:GabrielBD    | 项目源码 | 文件源码
def log_error(self, msg, *args, **kw):
        log.error(msg, *args)
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def log_error(self, msg, *args, **kw):
        log.error(msg, *args)
项目:flickr_downloader    作者:Denisolt    | 项目源码 | 文件源码
def log_error(self, msg, *args, **kw):
        log.error(msg, *args)
项目:threatdetectionservice    作者:flyballlabs    | 项目源码 | 文件源码
def log_error(self, msg, *args, **kw):
        log.error(msg, *args)
项目:oa_qian    作者:sunqb    | 项目源码 | 文件源码
def log_error(self, msg, *args, **kw):
        log.error(msg, *args)
项目:RealtimePythonChat    作者:quangtqag    | 项目源码 | 文件源码
def log_error(self, msg, *args, **kw):
        log.error(msg, *args)
项目:Indushell    作者:SecarmaLabs    | 项目源码 | 文件源码
def log_error(self, msg, *args, **kw):
        log.error(msg, *args)
项目:notebook-molecular-visualization    作者:Autodesk    | 项目源码 | 文件源码
def run(self):
        has_npm = self.has_npm()
        if not has_npm:
            log.error("`npm` unavailable. If you're running this command using sudo, "
                      "make sure `npm` is available to sudo")

        env = os.environ.copy()
        env['PATH'] = npm_path

        vjson = os.path.join(node_root, '.VERSION.json')
        with open(vjson, 'w') as vjsonfile:
            vjsonfile.write('{"version":"%s"}\n' % VERSION)

        if self.should_run_npm_install():
            log.info("Installing build dependencies with npm.  This may take a while...")
            check_call(['npm', 'install'], cwd=node_root, stdout=sys.stdout, stderr=sys.stderr)
            os.utime(self.node_modules, None)

        # TODO: do this with NPM/webpack, not in python
        shutil.copy(os.path.join(node_root, 'src', 'nbmolviz.css'),
                    os.path.join(here, 'nbmolviz', 'static', 'nbmolviz.css'))

        with open(self.verfile_path, 'w') as verfile:
            verfile.write(VERSION)

        for t in self.targets:
            if not os.path.exists(t):
                msg = 'Missing file: %s' % t
                if not has_npm:
                    msg += '\nnpm is required to build a development version of nbmolviz-js'
                raise ValueError(msg)

        print('Wrote version "%s" to "%s"' % (VERSION, self.verfile_path))

        # update package data in case this created new files
        update_package_data(self.distribution)


###################################################################
#   Actual setup command                                          #
###################################################################
项目:SHAREOpenRefineWkshop    作者:cmh2166    | 项目源码 | 文件源码
def log_error(self, msg, *args, **kw):
        log.error(msg, *args)
项目:Liljimbo-Chatbot    作者:chrisjim316    | 项目源码 | 文件源码
def log_error(self, msg, *args, **kw):
        log.error(msg, *args)
项目:leetcode    作者:thomasyimgit    | 项目源码 | 文件源码
def log_error(self, msg, *args, **kw):
        log.error(msg, *args)
项目:flask_system    作者:prashasy    | 项目源码 | 文件源码
def log_error(self, msg, *args, **kw):
        log.error(msg, *args)
项目:news-for-good    作者:thecodinghub    | 项目源码 | 文件源码
def log_error(self, msg, *args, **kw):
        log.error(msg, *args)
项目:CaScale    作者:Thatsillogical    | 项目源码 | 文件源码
def log_error(self, msg, *args, **kw):
        log.error(msg, *args)
项目:chihu    作者:yelongyu    | 项目源码 | 文件源码
def log_error(self, msg, *args, **kw):
        log.error(msg, *args)