qgis_deployment_toolbelt.utils.linux_utils module

Utilities specific for Linux.

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

qgis_deployment_toolbelt.utils.linux_utils.bash_user_which_file_to_store() Path

Determine which file to use to store environment variables.

Returns:

path to the file to use

Return type:

Path

qgis_deployment_toolbelt.utils.linux_utils.delete_environment_variable(envvar_name: str, scope: Literal['system', 'user'] = 'user') bool

Remove environment variable from Linux profile file.

Parameters:
  • envvar_name (str) – environment variable name (= key) to remove

  • scope (str, optional) – environment variable scope. Must be “user” or “system”, defaults to “user”. Defaults to “user”.

Returns:

True if environment variable successfully removed or False if not

Return type:

bool

qgis_deployment_toolbelt.utils.linux_utils.find_key_from_values(value_to_find: str) str | None

Finds the key corresponding to a given value in a dictionary where values are tuples.

Parameters:

value_to_find (str) – The value to search for in the dictionary values.

Returns:

The key corresponding to the found value. Returns None if the value

is not found.

Return type:

str | None

qgis_deployment_toolbelt.utils.linux_utils.get_environment_variable(envvar_name: str, scope: str = 'user') str | None

Get environment variable from Linux profile file.

Parameters:
  • envvar_name (str) – environment variable name (= key) to retrieve

  • scope (str, optional) – environment variable scope. Must be “user” or “system”, defaults to “user”. Defaults to “user”.

Returns:

environment variable value or None if not found

Return type:

str | None

qgis_deployment_toolbelt.utils.linux_utils.get_profile_file(scope: Literal['system', 'user']) Path | None

Get Linux profile file depending on shell and scope.

Parameters:

scope (str, optional) – environment variable scope. Must be “user” or “system”, defaults to “user”. Defaults to “user”.

Returns:

profile file path or None if not found

Return type:

str | None

qgis_deployment_toolbelt.utils.linux_utils.refresh_environment() bool

Just here to be equivalent with Windows logic.

TODO: refacto merging win32 methods in a single class.

Returns:

always True

Return type:

bool

qgis_deployment_toolbelt.utils.linux_utils.set_environment_variable(envvar_name: str, envvar_value: str | bool | int, scope: str = 'user') bool

Set environment variable in Linux profile file.

Parameters:
  • envvar_name (str) – environment variable name (= key) to set

  • envvar_value (str) – environment variable value to set

  • scope (str, optional) – environment variable scope. Must be “user” or “system”, defaults to “user”. Defaults to “user”.

Returns:

True if environment variable correctly set or False if not

Return type:

bool