Show More
@@ -708,18 +708,29 b' def _string_setting(settings, name, defa' | |||||
708 |
|
708 | |||
709 |
|
709 | |||
710 | def _substitute_values(mapping, substitutions): |
|
710 | def _substitute_values(mapping, substitutions): | |
|
711 | result = {} | |||
711 |
|
712 | |||
712 | try: |
|
713 | try: | |
713 | result = { |
|
714 | for key, value in mapping.items(): | |
|
715 | # initialize without substitution first | |||
|
716 | result[key] = value | |||
|
717 | ||||
714 | # Note: Cannot use regular replacements, since they would clash |
|
718 | # Note: Cannot use regular replacements, since they would clash | |
715 | # with the implementation of ConfigParser. Using "format" instead. |
|
719 | # with the implementation of ConfigParser. Using "format" instead. | |
716 | key: value.format(**substitutions) |
|
720 | try: | |
717 | for key, value in mapping.items() |
|
721 | result[key] = value.format(**substitutions) | |
718 | } |
|
722 | except KeyError as e: | |
719 | except KeyError as e: |
|
723 | env_var = '{}'.format(e.args[0]) | |
720 | raise ValueError( |
|
724 | ||
721 | 'Failed to substitute env variable: {}. ' |
|
725 | msg = 'Failed to substitute: `{key}={{{var}}}` with environment entry. ' \ | |
722 | 'Make sure you have specified this env variable without ENV_ prefix'.format(e)) |
|
726 | 'Make sure your environment has {var} set, or remove this ' \ | |
|
727 | 'variable from config file'.format(key=key, var=env_var) | |||
|
728 | ||||
|
729 | if env_var.startswith('ENV_'): | |||
|
730 | raise ValueError(msg) | |||
|
731 | else: | |||
|
732 | log.warning(msg) | |||
|
733 | ||||
723 | except ValueError as e: |
|
734 | except ValueError as e: | |
724 | log.warning('Failed to substitute ENV variable: %s', e) |
|
735 | log.warning('Failed to substitute ENV variable: %s', e) | |
725 | result = mapping |
|
736 | result = mapping |
General Comments 0
You need to be logged in to leave comments.
Login now