host.local_host¶
Local host implementation — runs commands on the machine otto itself is running on.
LocalHost is a concrete BaseHost that spawns
subprocesses and manages a persistent local shell session, mirroring the API of
UnixHost without any network transport. File
transfers are handled by LocalFileTransfer (a shutil-backed
BaseFileTransfer subclass) so progress reporting
works uniformly across all host backends.
-
class otto.host.local_host.LocalFileTransfer(name: str, max_filename_len: int =
255)¶ Bases:
BaseFileTransferFile transfer for
LocalHost— a local copy viashutil.copy2().Concrete
BaseFileTransferso the ABC’s progress contract holds uniformly across every backend in the host fleet (Unix’sUnixFileTransfer, embedded’sEmbeddedFileTransfer, and this one). Per-file completion is the granularity —shutil.copy2is a single blocking C call with no progress hook, the analogue of an embeddedfs read.
- class otto.host.local_host.LocalHost(log: ~otto.logger.mode.LogMode = LogMode.NORMAL, resources: set[str] = <factory>, products: list[~otto.host.product.Product] = <factory>, power_control: ~otto.host.power.PowerController | None = None)¶
Bases:
PosixPrivilege,PosixFileOps,BaseHostA host that runs commands on the local machine via a persistent shell session.
Implements the full
BaseHostAPI (run, oneshot, put, get, open_session, send, expect, is_reachable) without any network transport. Shell state (working directory, environment variables) persists acrossruncalls through aSessionManager-backed local session;oneshotbypasses it and spawns an independent subprocess, making concurrent calls safe. File transfers delegate toLocalFileTransfer.- log : LogMode¶
Standing per-host logging disposition.
QUIETkeeps this host’s command I/O inverbose.logbut off the console;NEVERredacts it everywhere (warnings/errors are unaffected).
- power_control : PowerController | None¶
Always None — LocalHost/DockerContainerHost are not power-controlled.
-
async oneshot(cmd: str, timeout: float | None =
None, log: LogMode =LogMode.NORMAL) CommandStatus¶ Run a command in a fresh subprocess (stateless, concurrent-safe).
Each call spawns an independent process — no state persists between calls, and multiple oneshot() calls can run concurrently via asyncio.gather().
- async open_session(name: str) HostSession¶
Open a named persistent shell session.
-
async send(text: str, log: LogMode =
LogMode.NORMAL) None¶ Send raw text to the host’s persistent session.
-
async expect(pattern: str | Pattern[str], timeout: float =
10.0) str¶ Wait for a pattern in the host’s session output stream.
- async get(src_files: ~types.Annotated[list[~pathlib.Path] | ~pathlib.Path, ~otto.utils.Arg(variadic=True, elem_type=~pathlib.Path, name=None, help=Remote file(s) to download.)], dest_dir: ~pathlib.Path, show_progress: ~typing.Annotated[bool, <otto.utils._Exclude object at 0x7c9c99ff98c0>] = True) tuple[Status, str]¶
Copy files to dest_dir on the local filesystem.
Delegates to
LocalFileTransferso progress reporting flows through the sameBaseFileTransfermachinery as Unix and embedded backends.
- async put(src_files: ~types.Annotated[list[~pathlib.Path] | ~pathlib.Path, ~otto.utils.Arg(variadic=True, elem_type=~pathlib.Path, name=None, help=Local file(s) to upload.)], dest_dir: ~pathlib.Path, show_progress: ~typing.Annotated[bool, <otto.utils._Exclude object at 0x7c9c99ff98c0>] = True) tuple[Status, str]¶
Copy files to dest_dir on the local filesystem.
Delegates to
LocalFileTransfer; seeget().