CLI¶
CLI access¶
-
exos.api.
exec_cli
(cmds, timeout=0)[source]¶ Send a list of commands to the CLI and return the output. cmds must be a list of strings. This call will block until all commands have completed. The output is returned as a string.
If ignore_errors is False, the default, execution will stop after the first failed command and raise a
CLICommandError
.
-
exos.api.
exec_cli_async
(cmds, callback, timeout=0)[source]¶ Send a list of commands to the CLI and return the output via a callback. This function returns immediately. cmds must be a list of strings.
callback is called with each block of output, which is typically a single line. The first parameter to callback is either
CLI_EVENT_EXEC_REPLY
, indicating this is just another block of output, orCLI_EVENT_EXEC_DONE
, indicating a command has completed. ACLI_EVENT_EXEC_DONE
is passed for each command sent.The second parameter to callback is the output itself, as a string.
-
exos.api.
CLI_EVENT_EXEC_REPLY
¶ Used in an
exec_cli_async()
callback to indicate this is part of the output.
-
exos.api.
CLI_EVENT_EXEC_DONE
¶ Used in an
exec_cli_async()
callback to indicate the current command has finished.
-
exos.api.
CLI_EVENT_EXEC_TIMEOUT
¶ Used in an
exec_cli_async()
callback to indicate the current command has timed out.
Extending the CLI¶
A Python process can extend the CLI. This is especially useful when coupled with the cmbackend.
Namespaces¶
EXOS namespaces can be used in the CLI for tab completion. Each namespace is a list of strings with an optional value.
-
exos.api.
namespace_add
(namespace, entry, value=None, vr_name=None)[source]¶ Add entry and optional value to the CLI namespace. Optionally scope the namespace to a vr_name.