How to use the west.log 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 / runners / core.py View on Github external
def call(self, cmd):
        '''Subclass subprocess.call() wrapper.

        Subclasses should use this method to run command in a
        subprocess and get its return code, rather than
        using subprocess directly, to keep accurate debug logs.
        '''
        quoted = quote_sh_list(cmd)

        if JUST_PRINT:
            log.inf(quoted)
            return 0

        log.dbg(quoted)
        return subprocess.call(cmd)
github zephyrproject-rtos / west / src / west / runners / nrfjprog.py View on Github external
def get_board_snr_from_user(self):
        snrs = self.check_output(['nrfjprog', '--ids'])
        snrs = snrs.decode(sys.getdefaultencoding()).strip().splitlines()

        if len(snrs) == 0:
            raise RuntimeError('"nrfjprog --ids" did not find a board; '
                               'is the board connected?')
        elif len(snrs) == 1:
            board_snr = snrs[0]
            if board_snr == '0':
                raise RuntimeError('"nrfjprog --ids" returned 0; '
                                   'is a debugger already connected?')
            return board_snr

        log.dbg("Refusing the temptation to guess a board",
                level=log.VERBOSE_EXTREME)

        # Use of print() here is advised. We don't want to lose
        # this information in a separate log -- this is
        # interactive and requires a terminal.
        print('There are multiple boards connected.')
        for i, snr in enumerate(snrs, 1):
            print('{}. {}'.format(i, snr))

        p = 'Please select one with desired serial number (1-{}): '.format(
                len(snrs))
        while True:
            value = input(p)
            try:
                value = int(value)
            except ValueError:
github zephyrproject-rtos / zephyr / scripts / meta / west / runners / intel_s1000.py View on Github external
def print_gdbserver_message(self, gdb_port):
        log.inf('Intel S1000 GDB server running on port {}'.format(gdb_port))
github zephyrproject-rtos / west / src / west / app / main.py View on Github external
self.manifest = Manifest.from_file(topdir=self.topdir)
        except (ManifestVersionError, MalformedManifest, MalformedConfig,
                FileNotFoundError, ManifestImportFailed) as e:
            # Defer exception handling to WestCommand.run(), which uses
            # handle_builtin_manifest_load_err() to decide what to do.
            #
            # Make sure to update that function if you change the
            # exceptions caught here. Unexpected exceptions should
            # propagate up and fail fast.
            #
            # This might be OK, e.g. if we're running 'west config
            # manifest.path foo' to fix the MalformedConfig error, but
            # there's no way to know until we've parsed the command
            # line arguments.
            if isinstance(e, _ManifestImportDepth):
                log.wrn('recursion depth exceeded during manifest resolution; '
                        'your manifest likely contains an import loop. '
                        'Run "west -v manifest --resolve" to debug.')
            self.mle = e
github zephyrproject-rtos / zephyr / scripts / west_commands / run_common.py View on Github external
log.inf('Build directory:', colorize=True)
    log.inf(INDENT + build_dir)
    log.inf('Board:', colorize=True)
    log.inf(INDENT + cache['CACHED_BOARD'])
    log.inf('CMake cache:', colorize=True)
    log.inf(INDENT + cache.cache_file)
    log.inf(runner, 'is available:', 'yes' if available else 'no',
            colorize=True)
    _dump_runner_opt_help(runner, cls)
    _dump_runner_config(cfg, '', indent)
    if available:
        _dump_runner_cached_opts(cache, runner, '', indent)
    _dump_runner_caps(cls, '')
    if not available:
        log.wrn('Runner', runner, 'is not configured in this build.')
github zephyrproject-rtos / west / src / west / app / project.py View on Github external
# the new HEAD (e.g. if this is a topic branch the
        # user is working on and the remote hasn't changed),
        # print a message that makes it easy to get back,
        # no matter where in the workspace os.getcwd() is.
        log.wrn(f'left behind {project.name} branch "{branch}"; '
                f'to switch back to it (fast forward), use: '
                f'git -C {rel} checkout {branch}')
        log.dbg('(To do this automatically in the future,',
                'use "west update --keep-descendants".)')
    else:
        # Tell the user how they could rebase by hand, and
        # point them at west update --rebase.
        log.wrn(f'left behind {project.name} branch "{branch}"; '
                f'to rebase onto the new HEAD: '
                f'git -C {rel} rebase {sha} {branch}')
        log.dbg('(To do this automatically in the future,',
                'use "west update --rebase".)')
github zephyrproject-rtos / west / src / west / commands / run_common.py View on Github external
command.name in cls.capabilities().commands}
    available = [r for r in cache.get_list('ZEPHYR_RUNNERS') if r in all_cls]
    available_cls = {r: all_cls[r] for r in available if r in all_cls}

    default_runner = cache.get(cached_runner_var)
    cfg = cached_runner_config(build_dir, cache)

    log.inf('All Zephyr runners which support {}:'.format(command.name),
            colorize=True)
    for line in util.wrap(', '.join(all_cls.keys()), INDENT):
        log.inf(line)
    log.inf('(Not all may work with this build, see available runners below.)',
            colorize=True)

    if cache is None:
        log.warn('Missing or invalid CMake cache {}; there is no context.',
                 'Use --build-dir to specify the build directory.')
        return

    log.inf('Build directory:', colorize=True)
    log.inf(INDENT + build_dir)
    log.inf('Board:', colorize=True)
    log.inf(INDENT + board)
    log.inf('CMake cache:', colorize=True)
    log.inf(INDENT + cache_file)

    if not available:
        # Bail with a message if no runners are available.
        msg = ('No runners available for {}. '
               'Consult the documentation for instructions on how to run '
               'binaries on this target.').format(board)
        for line in util.wrap(msg, ''):
github NordicPlayground / fw-nrfconnect-nrf / scripts / west_commands / ncs_commands.py View on Github external
def do_run(self, args, unknown_args):
        self.check_west_version()
        if args.files and len(args.projects) != 1:
            self.parser.error('--file used, so expected 1 project argument,' +
                              ' but got: {}'.format(len(args.projects)))
        self.setup_upstream_downstream(args)

        for name, project in self.ncs_pmap.items():
            if name in self.z_pmap and name != 'manifest':
                z_project = self.z_pmap[name]
            elif name == 'zephyr':
                z_project = self.z_pmap['manifest']
            else:
                log.dbg('skipping downstream project {}'.format(name),
                        level=log.VERBOSE_VERY)
                continue
            self.print_loot(name, project, z_project, args)