From 07d0bcc7526ee643b6f8c04e00a254493070b88c Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Wed, 24 Jul 2024 12:10:11 +0200 Subject: [PATCH] Remove empty environment variable --- client/ayon_core/hooks/pre_filter_farm_environments.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/client/ayon_core/hooks/pre_filter_farm_environments.py b/client/ayon_core/hooks/pre_filter_farm_environments.py index cabd705d81..0f83c0d3e0 100644 --- a/client/ayon_core/hooks/pre_filter_farm_environments.py +++ b/client/ayon_core/hooks/pre_filter_farm_environments.py @@ -14,7 +14,6 @@ class FilterFarmEnvironments(PreLaunchHook): - skipping (list) of environment variable keys - removing value in environment variable: - supports regular expression in pattern - - doesn't remove env var if value empty! """ order = 1000 @@ -55,12 +54,16 @@ class FilterFarmEnvironments(PreLaunchHook): def _modify_environment_variables(self, calculated_env, matching_profile): """Modify environment variable values.""" for env_item in matching_profile["replace_in_environment"]: - value = calculated_env.get(env_item["environment_key"]) + key = env_item["environment_key"] + value = calculated_env.get(key) if not value: continue value = re.sub(value, env_item["pattern"], env_item["replacement"]) - calculated_env[env_item["environment_key"]] = value + if value: + calculated_env[key] = value + else: + calculated_env.pop(key) def _skip_environment_variables(self, calculated_env, matching_profile): """Skips list of environment variable names"""