Shell environment
shell_environment ¶
Code that helps manage and maintain the build environment.
This management includes PATH, PYTHONPATH and ENV Variables.
ShellEnvironment ¶
An active copy of the current OS environment.
Allows for easy manipulation of the environment including taking screenshots (checkpoints) that are stored and can be accessed later.
checkpoint ¶
checkpoint() -> int
Creates a checkpoint in time.
Checkpoint stores the following: 1. active_environment 2. active_path 3. active_pypath 4. active_buildvars
restore_initial_checkpoint ¶
restore_initial_checkpoint() -> None
Restore the initial checkpoint made.
set_path ¶
set_path(new_path: str) -> None
Set the path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
new_path |
str
|
path to override with |
required |
set_pypath ¶
set_pypath(new_path: str) -> None
Set the pypath.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
new_path |
str
|
path to override with |
required |
append_path ¶
append_path(path_element: str) -> None
Append to the end of path.
if path_element already exists within path it will be removed from the current location and appended to the end
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path_element |
str
|
path element to append |
required |
insert_path ¶
insert_path(path_element: str) -> None
Insert at front of the path.
if path_element already exists within path it will be removed from the current location and prepended to the front
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path_element |
str
|
path element to insert |
required |
append_pypath ¶
append_pypath(path_element: str) -> None
Append to the end of pypath.
if path_element already exists within pypath it will be removed from the current location and appended to the end
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path_element |
str
|
path element to append |
required |
insert_pypath ¶
insert_pypath(path_element: str) -> None
Insert at front of the pypath.
if path_element already exists within pypath it will be removed from the current location and prepended to the front
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path_element |
str
|
path element to insert |
required |
replace_path_element ¶
replace_path_element(
old_path_element: str, new_path_element: str
) -> None
Replaces the PATH element.
Generates a new PATH by iterating through the old PATH and replacing old_path_element with new_path_element where it is found.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
old_path_element |
str
|
element to replace |
required |
new_path_element |
str
|
element to replace with |
required |
replace_pypath_element ¶
replace_pypath_element(
old_pypath_element: str, new_pypath_element: str
) -> None
Replaces the PYPATH element.
Generates a new PYPATH by iterating through the old PYPATH and replacing old_pypath_element with new_pypath_element where it is found.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
old_pypath_element |
str
|
element to replace |
required |
new_pypath_element |
str
|
element to replace with |
required |
remove_path_element ¶
remove_path_element(path_element: str) -> None
Removes the PATH element.
Generates a new PATH by iterating through the old PATH and removing path_element if it is found.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path_element |
str
|
path element to remove |
required |
remove_pypath_element ¶
remove_pypath_element(pypath_element: str) -> None
Removes the PYPATH element.
Generates a new PYPATH by iterating through the old PYPATH and removing pypath_element if it is found.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pypath_element |
str
|
pypath element to remove |
required |
get_build_var ¶
get_build_var(var_name: str) -> str
Gets the build variable.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
var_name |
str
|
variable to get the value of |
required |
set_build_var ¶
set_build_var(var_name: str, var_data: str) -> None
Sets the variable as internal build variable.
Unlike set_shell_var, var_data can be None
; this sets var_name as a non-valued
build variable (e.g. E1000_ENABLE). Additional information can be found at:
https://www.tianocore.org/edk2-pytool-extensions/integrate/build/#setting-getting-environment-variables.
Note
Variables set in this manner are only accessable inside stuart, and are not an os environment variable. Refer to set_shell_var to set an os environment variable.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
var_name |
str
|
variable to set the value for |
required |
var_data |
obj
|
data to set |
required |
get_shell_var ¶
get_shell_var(var_name: str) -> str
Gets the shell variable.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
var_name |
str
|
variable to get the value of |
required |
Returns:
Type | Description |
---|---|
str
|
value associated with the var name |
set_shell_var ¶
set_shell_var(var_name: str, var_data: str) -> None
Sets the variable as an OS environment variable.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
var_name |
str
|
variable to set the value for |
required |
var_data |
str
|
data to set |
required |
Raises:
Type | Description |
---|---|
ValueError
|
var_data is None |
GetEnvironment ¶
GetEnvironment() -> ShellEnvironment
GetBuildVars ¶
GetBuildVars() -> var_dict.VarDict
The current checkpoint buildvar values.
Returns:
Type | Description |
---|---|
VarDict
|
A special dictionary containing build vars |
CheckpointBuildVars ¶
CheckpointBuildVars() -> None
Creates a checkpoint [a screenshot in time] of all current build var values.
RevertBuildVars ¶
RevertBuildVars() -> None
Reverts all build var values to the most recent checkpoint.