BaseEnvShell
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
CONFIG_FILE_NAME: str
env_file_path: str
env_hash: str
env_name: str
working_dir: str
Functions
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_name | str | Name of the environment. this name will be shown in the env list. if not provided, a name is generated | |
env_file_path | Union | Path to the env file. this file must contained dependencies for the virtual env and str | |
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.
: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
Name | Type | Default value | Description |
---|---|---|---|
user_cmd | Union |
str |
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 |
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 |
Run a command in a shell. The logs of the command will be dispatched to the message dispatcher during the execution.
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 | True | If true, the command is run in a shell, defaults to false , optional |
int |
Uninstall the virtual env. Return true if the env was uninstalled, False if it was already uninstalled or an error occured.
bool |
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 json info file content
Name | Type | Default value | Description |
---|---|---|---|
folder_path | str |
VEnvCreationInfo |
Returns the type of the env
Literal |
Create a hash from the env_str to generate a unique env dir name.
Name | Type | Default value | Description |
---|---|---|---|
env_str | str |
str |