How to use the bundlewrap.utils.ui.io.debug function in bundlewrap

To help you get started, we’ve selected a few bundlewrap 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 bundlewrap / bundlewrap / bundlewrap / signals.py View on Github external
if not QUIT_EVENT.is_set():
        QUIT_EVENT.set()
        io.stderr(_(
            "{x} {signal}  canceling pending tasks... "
            "(hit CTRL+C again for immediate dirty exit)"
        ).format(
            signal=bold(_("SIGINT")),
            x=blue("i"),
        ))
    else:
        io.stderr(_("{x} {signal}  cleanup interrupted, exiting...").format(
            signal=bold(_("SIGINT")),
            x=blue("i"),
        ))
        for ssh_pid in SSH_PIDS:
            io.debug(_("killing SSH session with PID {pid}").format(pid=ssh_pid))
            try:
                kill(ssh_pid, SIGINT)
            except ProcessLookupError:
                pass
        io._clear_last_job()
        _exit(1)
github bundlewrap / bundlewrap / bundlewrap / metagen.py View on Github external
def __initial_run_for_node(self, node_name):
        io.debug(f"initial metadata run for {node_name}")
        node = self.get_node(node_name)
        self.__metastacks[node_name] = Metastack()

        # randomize order to increase chance of exposing clashing defaults
        for defaults_name, defaults in randomize_order(node.metadata_defaults):
            self.__metastacks[node_name]._set_layer(
                2,
                defaults_name,
                defaults,
            )
        self.__metastacks[node_name]._cache_partition(2)

        group_order = _flatten_group_hierarchy(node.groups)
        for group_name in group_order:
            self.__metastacks[node_name]._set_layer(
                0,
github bundlewrap / bundlewrap / bundlewrap / deps.py View on Github external
dep_item.triggered and not dep_item.has_been_triggered:
                # don't skip dummy items because of untriggered members
                # see issue #151; separate elif for clarity
                item._deps.remove(dep_item.id)
            elif dep_item.id in item._concurrency_deps:
                # don't skip items just because of concurrency deps
                # separate elif for clarity
                item._deps.remove(dep_item.id)
            else:
                removed_items.append(item)

    for item in removed_items:
        items.remove(item)

    if removed_items:
        io.debug(
            "skipped these items because they depend on {item}, which was "
            "skipped previously: {skipped}".format(
                item=dep_item.id,
                skipped=", ".join([item.id for item in removed_items]),
            )
        )

    all_recursively_removed_items = []
    for removed_item in removed_items:
        if removed_item.cascade_skip:
            items, recursively_removed_items = \
                remove_item_dependents(items, removed_item, skipped=skipped)
            all_recursively_removed_items += recursively_removed_items
        else:
            items = remove_dep_from_items(items, removed_item.id)
github bundlewrap / bundlewrap / bundlewrap / items / kubernetes.py View on Github external
def log_error(run_result):
    if run_result.return_code != 0:
        io.debug(run_result.stdout.decode('utf-8'))
        io.debug(run_result.stderr.decode('utf-8'))
github bundlewrap / bundlewrap / bundlewrap / itemqueue.py View on Github external
def _fire_triggers_for_item(self, item):
        for triggered_item_id in item.triggers:
            try:
                triggered_item = find_item(
                    triggered_item_id,
                    self.all_items,
                )
                triggered_item.has_been_triggered = True
            except NoSuchItem:
                io.debug(_(
                    "{item} tried to trigger {triggered_item}, "
                    "but it wasn't available. It must have been skipped previously."
                ).format(
                    item=item.id,
                    triggered_item=triggered_item_id,
                ))
github bundlewrap / bundlewrap / bundlewrap / node.py View on Github external
]

        for group in group_order:
            if getattr(group, attr) is not None:
                attr_source = "group:{}".format(group.name)
                attr_value = getattr(group, attr)

        if getattr(self, "_{}".format(attr)) is not None:
            attr_source = "node"
            attr_value = getattr(self, "_{}".format(attr))

        if attr_value is None:
            attr_source = "default"
            attr_value = default

        io.debug(_("node {node} gets its {attr} attribute from: {source}").format(
            node=self.name,
            attr=attr,
            source=attr_source,
        ))
        return attr_value
    method.__name__ = "_group_attr_{}".format(attr)  # required for cached_property
github bundlewrap / bundlewrap / bundlewrap / operations.py View on Github external
def run(hostname, command, ignore_failure=False, add_host_keys=False, log_function=None):
    """
    Runs a command on a remote system.
    """
    # LineBuffer objects take care of always printing complete lines
    # which have been properly terminated by a newline. This is only
    # relevant when using `bw run`.
    # Does nothing when log_function is None.
    stderr_lb = LineBuffer(log_function)
    stdout_lb = LineBuffer(log_function)

    io.debug("running on {host}: {command}".format(command=command, host=hostname))

    # Create pipes which will be used by the SSH child process. We do
    # not use subprocess.PIPE because we need to be able to continuously
    # check those pipes for new output, so we can feed it to the
    # LineBuffers during `bw run`.
    stdout_fd_r, stdout_fd_w = pipe()
    stderr_fd_r, stderr_fd_w = pipe()

    # Launch OpenSSH. It's important that SSH gets a dummy stdin, i.e.
    # it must *not* read from the terminal. Otherwise, it can steal user
    # input.
    ssh_process = Popen(
        [
            "ssh",
            "-o",
            "StrictHostKeyChecking=no" if add_host_keys else "StrictHostKeyChecking=yes",
github bundlewrap / bundlewrap / bundlewrap / concurrency.py View on Github external
timeout=0.1,
            )
            if completed:
                break
        future = completed.pop()

        start_time = self.pending_futures[future]['start_time']
        task_id = self.pending_futures[future]['task_id']
        worker_id = self.pending_futures[future]['worker_id']

        del self.pending_futures[future]
        self.idle_workers.add(worker_id)

        exception = future.exception()
        if exception:
            io.debug(_(
                "exception raised while executing task {task} on worker #{worker} "
                "of worker pool {pool}"
            ).format(
                pool=self.pool_id,
                task=task_id,
                worker=worker_id,
            ))
            if not hasattr(exception, '__traceback__'):  # Python 2
                exception.__traceback__ = future.exception_info()[1]
            exception.__task_id = task_id
            raise exception
        else:
            io.debug(_(
                "worker pool {pool} delivering result of {task} on worker #{worker}"
            ).format(
                pool=self.pool_id,