Merge pull request #117 from gyptazy/fix/115-ignore-schedule-bool-parsing

fix: Fix that a scheduler time definition of 1 (int) gets wrongly interpreted as a bool.
This commit is contained in:
Florian
2024-11-06 08:47:10 +01:00
committed by GitHub
2 changed files with 10 additions and 5 deletions

View File

@@ -0,0 +1,2 @@
fixed:
- Fix that a scheduler time definition of 1 (int) gets wrongly interpreted as a bool (by @gyptazy). [#115]

13
proxlb
View File

@@ -295,18 +295,21 @@ def initialize_config_options(config_path):
def __update_config_parser_bools(proxlb_config):
""" Update bools in config from configparser to real bools """
info_prefix = 'Info: [config-bool-converter]:'
info_prefix = 'Info: [config-bool-converter]:'
ignore_sections = ['schedule']
# Normalize and update config parser values to bools.
for section, option_value in proxlb_config.items():
if option_value in [1, '1', 'yes', 'Yes', 'true', 'True', 'enable']:
logging.info(f'{info_prefix} Converting {section} to bool: True.')
proxlb_config[section] = True
if section not in ignore_sections:
logging.info(f'{info_prefix} Converting {section} to bool: True.')
proxlb_config[section] = True
if option_value in [0, '0', 'no', 'No', 'false', 'False', 'disable']:
logging.info(f'{info_prefix} Converting {section} to bool: False.')
proxlb_config[section] = False
if section not in ignore_sections:
logging.info(f'{info_prefix} Converting {section} to bool: False.')
proxlb_config[section] = False
return proxlb_config