qgis_deployment_toolbelt.jobs.job_environment_variables module

Tools to manage the environment setup (variables, etc.)

Author: Julien Moura (https://github.com/guts)

class qgis_deployment_toolbelt.jobs.job_environment_variables.EnvironmentVariableOptions(*, action: Literal['add', 'remove'], name: Annotated[str, _PydanticGeneralMetadata(pattern='^[^=]+$')], scope: Literal['system', 'user'] = 'user', value: bool | int | str | list | None = None, value_type: Literal['bool', 'path', 'str', 'url'] = 'str', qgis_ini_use: bool = False)

Bases: JobOptions

Options of one environment variable managed by the manage-env-vars job: the with key of the job is a list of them.

_abc_impl = <_abc._abc_data object>
action: Literal['add', 'remove']

what to do with the environment variable

model_config = {'extra': 'forbid', 'frozen': True, 'strict': True, 'validate_default': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str

not empty, without ‘=’ (forbidden char

Type:

name of the environment variable

qgis_ini_use: bool

for a path, replace backslashs by slashs to use it in a QGIS .ini file

scope: Literal['system', 'user']

level of the environment variable

value: bool | int | str | list | None

value to set. Required to add the variable, ignored to remove it.

value_type: Literal['bool', 'path', 'str', 'url']

type of the value, to prepare it (path expansion, URL check…)

class qgis_deployment_toolbelt.jobs.job_environment_variables.JobEnvironmentVariables(options: list[dict])

Bases: GenericJob

Class to manage the environment variables of QGIS installation.

ID: str = 'manage-env-vars'
OPTIONS

alias of EnvironmentVariableOptions

__init__(options: list[dict]) → None

Instantiate the class.

Parameters:

options (list[dict]) – list set in the with key of the scenario step, one item per environment variable to set or remove, see EnvironmentVariableOptions

Raises:
_abc_impl = <_abc._abc_data object>
options: list[EnvironmentVariableOptions]
prepare_value(value: str, value_type: str | None = None, qgis_ini_use: bool = False) → str

Prepare value to be used in the environment variable.

It performs some checks or operations depending on value type: user and

variable expansion, check if URL is valid, etc.

Parameters:
  • value (str) – value to prepare.

  • value_type (str, optional) – type of input value. Defaults to “str”.

  • qgis_ini_use (bool, optional) – replace backslash by slash for path value_type. Defaults to False.

Returns:

prepared value.

Return type:

str

run() → None

Apply environment variables from dictionary to the system.