ShellProxy
Shell task proxy.
This class is a proxy to Shell commandes. It allow running commands in a shell and get the output and stdout.
Attributes
working_dir: str
Functions
summary
If not provided, an new temp directory is created. defaults to None
Can be useful to log command outputs in task's logs. defaults to None
Parameters:
Name | Type | Default value | Description |
---|---|---|---|
working_dir | str | Working directory for the shell (all command will be executed from this dir). , optional | |
message_dispatcher | MessageDispatcher | If provided, the output of the command will be redirected to the dispatcher. , optional |
Attach a custom observer to the shell proxy. The logs of the proxy will be dispatch to the observer
Parameters:
Name | Type | Default value | Description |
---|---|---|---|
observer | MessageObserver |
Attach a progress_bar to the shell proxy. The logs of the proxy will be dispatch to the progress_bar logs
Parameters:
Name | Type | Default value | Description |
---|---|---|---|
progress_bar | ProgressBar |
Run a command in a shell and return the output.
:raises Exception: description
Parameters:
Name | Type | Default value | Description |
---|---|---|---|
cmd | Union | Command to run [list, str] | |
env | dict | Environment variables to pass to the shell, defaults to none , optional | |
shell_mode | bool | False | If true, the command is run in a shell, defaults to false , optional |
text | bool | True | If true, the output is returned as a string, defaults to true , optional |
Return type:
Any |
Get the message dispatcher
Return type:
MessageDispatcher |
Log an error message using the dispatcher
Parameters:
Name | Type | Default value | Description |
---|---|---|---|
message | str |
Log an info message using the dispatcher
Parameters:
Name | Type | Default value | Description |
---|---|---|---|
message | str |
Log a warining message using the dispatcher
Parameters:
Name | Type | Default value | Description |
---|---|---|---|
message | str |
Run a command in a shell. The logs of the command will be dispatched to the message dispatcher during the execution.
Parameters:
Name | Type | Default value | Description |
---|---|---|---|
cmd | Union | Command to run [list, str] | |
env | dict | Environment variables to pass to the shell, defaults to none , optional | |
shell_mode | bool | False | If true, the command is run in a shell, defaults to false , optional |
Return type:
int |