How to use the west.log.err function in west

To help you get started, we’ve selected a few west examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zephyrproject-rtos / west / src / west / app / main.py View on Github external
# Finally, run the command.
        try:
            if args.command in self.builtins:
                if self.mle:
                    self.handle_builtin_manifest_load_err(args)

                cmd = self.builtins.get(args.command, self.builtins['help'])
                cmd.run(args, unknown, self.topdir, manifest=self.manifest)
            else:
                self.run_extension(args.command, argv)
        except KeyboardInterrupt:
            sys.exit(0)
        except BrokenPipeError:
            sys.exit(0)
        except CalledProcessError as cpe:
            log.err(f'command exited with status {cpe.returncode}: '
                    f'{quote_sh_list(cpe.cmd)}', fatal=True)
            if args.verbose >= log.VERBOSE_EXTREME:
                log.banner('Traceback (enabled by -vvv):')
                traceback.print_exc()
            sys.exit(cpe.returncode)
        except ExtensionCommandError as ece:
            msg = f"extension command \"{args.command}\" couldn't be run"
            if ece.hint:
                msg += '\n  Hint: ' + ece.hint

            if args.verbose >= log.VERBOSE_EXTREME:
                log.err(msg, fatal=True)
                log.banner('Traceback (enabled by -vvv):')
                traceback.print_exc()
            else:
                tb_file = dump_traceback()
github zephyrproject-rtos / zephyr / scripts / meta / west / main.py View on Github external
if args.version:
        print_version_info()
        sys.exit(0)

    # Set up logging verbosity before doing anything else, so
    # e.g. verbose messages related to argument handling errors
    # work properly.
    log.set_verbosity(args.verbose)

    if IN_MULTIREPO_INSTALL:
        set_zephyr_base(args)

    if 'handler' not in args:
        if IN_MULTIREPO_INSTALL:
            log.err('west installation found (in {}), but no command given'.
                    format(west_dir()))
        else:
            log.err('no west command given')
        west_parser.print_help(file=sys.stderr)
        sys.exit(1)

    return args, unknown
github zephyrproject-rtos / west / src / west / app / project.py View on Github external
def manifest_rev_sha(project, stats, take_stats):
        # update() helper. Get the SHA for manifest-rev.

        try:
            if take_stats:
                start = perf_counter()
            return project.sha(QUAL_MANIFEST_REV)
            if take_stats:
                stats['get new manifest-rev SHA'] = perf_counter() - start
        except subprocess.CalledProcessError:
            # This is a sign something's really wrong. Add more help.
            log.err(f'no SHA for branch {MANIFEST_REV} '
                    f'in {project.name_and_path}; was the branch deleted?')
            raise
github zephyrproject-rtos / zephyr / scripts / west_commands / zephyr_ext_common.py View on Github external
def check_force(self, cond, msg):
        '''Abort if the command needs to be forced and hasn't been.

        The "forced" predicate must be in self.args.forced.

        If cond and self.args.force are both False, scream and die
        with message msg. Otherwise, return. That is, "cond" is a
        condition which means everything is OK; if it's False, only
        self.args.force being True can allow execution to proceed.
        '''
        if not (cond or self.args.force):
            log.err(msg)
            log.die('refusing to proceed without --force due to above error')
github zephyrproject-rtos / zephyr / scripts / meta / west / commands / build.py View on Github external
def _check_force(self, msg):
        if not self.args.force:
            log.err(msg)
            log.die('refusing to proceed without --force due to above error')
github zephyrproject-rtos / west / src / west / commands / build.py View on Github external
def _check_force(self, msg):
        if not self.args.force:
            log.err(msg)
            log.die('refusing to proceed without --force due to above error')
github zephyrproject-rtos / west / src / west / app / project.py View on Github external
def _handle_failed(self, args, failed):
        # Shared code for commands (like status, diff, update) that need
        # to do the same thing to multiple projects, but collect
        # and report errors if anything failed.

        if not failed:
            return
        elif len(failed) < 20:
            s = 's:' if len(failed) > 1 else ''
            projects = ', '.join(f'{p.name}' for p in failed)
            log.err(f'{self.name} failed for project{s} {projects}')
        else:
            log.err(f'{self.name} failed for multiple projects; see above')
        raise CommandError(1)