feat(updates): apply_updates takes an optional log callback (NetOrk/netork#1112)
UpdateMixin.apply_updates declares a keyword-only log, as harden_ssh_server does: it receives each line of the package manager's output as the host prints it. A driver that cannot stream does not call it and returns the output at the end, as before; the declaration stays compatible with every driver that implements it without the keyword.
This commit is contained in:
1 parent
e2970831f8
commit
059d97f6de
3 files changed
+47
-1
No files matched your search
@@ -12,6 +12,7 @@ this class in can never shadow a working implementation from a sibling base.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Callable
|
||||
from typing import TYPE_CHECKING, Any, Literal
|
||||
|
||||
from typing_extensions import TypedDict
|
||||
@@ -182,7 +183,12 @@ class UpdateMixin:
|
||||
"""
|
||||
...
|
||||
|
||||
def apply_updates(self, packages: list[str]) -> ApplyUpdatesResultDict:
|
||||
def apply_updates(
|
||||
self,
|
||||
packages: list[str],
|
||||
*,
|
||||
log: Callable[[str], None] | None = None,
|
||||
) -> ApplyUpdatesResultDict:
|
||||
"""
|
||||
Upgrades the given packages to the newest available version.
|
||||
|
||||
@@ -193,6 +199,10 @@ class UpdateMixin:
|
||||
:param packages: List of package names to upgrade. Each name must
|
||||
match ``^[a-zA-Z0-9_\\-\\+\\.]+$``; a :exc:`ValueError` is raised
|
||||
for any name that does not conform.
|
||||
:param log: Receives each line of the package manager's output as the
|
||||
host prints it, so a caller can follow a long run. A driver that
|
||||
cannot stream does not call it and returns the output at the end,
|
||||
as without it; ``output`` holds the whole output either way.
|
||||
:returns: A dict with:
|
||||
|
||||
* success (bool) – ``True`` if the package manager exited without error
|
||||
|
||||
Reference in new issue
Block a user