Shell task proxy.
This class is a proxy to Shell commandes. It allow running commands in a shell and get the output and stdout.
CONFIG_FILE_NAME: str
env_file_path: str
env_hash: str
env_name: str
working_dir: str
summary
will be used to create the env. If the env file has changed, the env will be recreated and
previous env will be deleted.
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
:raises Exception: description :raises Exception: description
Name | Type | Default value | Description |
---|---|---|---|
env_file_path | Union | Path to the env file. this file must contained dependencies for the virtual env and str | |
env_name | str | Name of the environment. this name will be shown in the env list. if not provided, a name is generated | |
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
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
Name | Type | Default value | Description |
---|---|---|---|
progress_bar | ProgressBar |
Creates the OS environment variables that are passed to the shell command
dict |
Run a command in a shell and return the output. There logs of the command are ignored.
:raises Exception: description
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 |
Any |
Create the env dir.
Path |
Returns True if the virtual env is installed. False otherwise
bool |
Format the user command. If the command is a list, must return a list.
Name | Type | Default value | Description |
---|---|---|---|
user_cmd | Union |
Union |
Returns the path of the config file used to create the env
str |
Returns the absolute path for the env dir base on a dir name. All env are in the global env dir.
str |
Get the message dispatcher
MessageDispatcher |
str |
Install the virtual env. Return True if the env was installed, False if it was already installed, or an error occured.
bool |
Log an error message using the dispatcher
Name | Type | Default value | Description |
---|---|---|---|
message | str |
Log an info message using the dispatcher
Name | Type | Default value | Description |
---|---|---|---|
message | str |
Log a warining message using the dispatcher
Name | Type | Default value | Description |
---|---|---|---|
message | str |
Read the env file and return its content.
str |
Run a command in a shell. The logs of the command will be dispatched to the message dispatcher during the execution.
⚠️ Warning ⚠️ Do not set to True if the command generates a lot of logs,
because logs are stored in database, defaults to False
⚠️ Warning ⚠️ Do not set to True if the command generates a lot of logs,
because logs are stored in database, defaults to True
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 |
dispatch_stdout | bool | False | If true, the stdout of the command is dispatched to the message dispatcher. , optional |
dispatch_stderr | bool | True | If true, the stderr of the command is dispatched to the message dispatcher. , optional |
int |
Run a command in a shell without blocking the thread. There logs of the command are ignored.
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 |
SysProc |
ShellProxyDTO |
Uninstall the virtual env. Return true if the env was uninstalled, False if it was already uninstalled or an error occured.
bool |
Returns the name of the class
Name | Type | Default value | Description |
---|---|---|---|
slugify | bool | False | True to slugify the class name if true, defaults to false , optional |
snakefy | bool | False | True to snakefy the class name if true, defaults to false , optional |
replace_uppercase | bool | False | Replace upper cases by "-" if true, defaults to false , optional |
str |
return true if the folder is a valid env folder
Name | Type | Default value | Description |
---|---|---|---|
folder_path | str |
bool |
Create the virtual environment from a string containing the environment definition.
The env dir name is generated from an hash of the env_str. So if the env_str is the same, the env dir name will be the same.
Name | Type | Default value | Description |
---|---|---|---|
env_str | str | ||
message_dispatcher | MessageDispatcher |
BaseEnvShell |
Returns the full name of the class
Name | Type | Default value | Description |
---|---|---|---|
slugify | bool | False | Slugify the returned class name if true, defaults to false , optional |
snakefy | bool | False | Snakefy the returned class name if true, defaults to false `` |
str |
Returns the json info file content
Name | Type | Default value | Description |
---|---|---|---|
folder_path | str |
VEnvCreationInfo |
Returns the type of the env
Literal |
Get the human name of the resource
str |
Get the short description of the resource
str |
Get the style of the resource
TypingStyle |
Get the typing name of the resource
str |
Create a hash from the env_str to generate a unique env dir name.
Name | Type | Default value | Description |
---|---|---|---|
env_str | str |
str |
Get all the classes that inherit this class
List |