qtoolkit.host.local module#

class qtoolkit.host.local.LocalHost(config: HostConfig | None = None)[source]#

Bases: BaseHost

execute(command: str | list[str], workdir: str | Path | None = None)[source]#

Execute the given command on the host

Note that the command is executed with shell=True, so commands can be exposed to command injection. Consider whether to escape part of the input if it comes from external users.

Parameters:

command (str or list of str) – Command to execute, as a str or list of str

Returns:

  • stdout (str) – Standard output of the command

  • stderr (str) – Standard error of the command

  • exit_code (int) – Exit code of the command.

mkdir(directory, recursive=True, exist_ok=True) bool[source]#

Create directory on the host.

write_text_file(filepath, content) None[source]#

Write content to a file on the host.