Upgrade WEEWX_ROOT for V5

This commit is contained in:
Tom Keffer
2023-12-03 15:12:08 -08:00
parent 809baeec9c
commit b39b0cafd9
2 changed files with 17 additions and 2 deletions

View File

@@ -129,7 +129,7 @@ class ConfigTest(unittest.TestCase):
def test_upgrade_v43(self):
"""Test an upgrade of the stock v4.1 weewx.conf to V4.2"""
# Start with the Version 4.1 weewx.conf file:
# Start with the Version 4.2 weewx.conf file:
config_dict = configobj.ConfigObj('weewx42.conf', encoding='utf-8')
# Upgrade the V4.2 configuration dictionary to V4.3:

View File

@@ -52,6 +52,8 @@ def update_config(config_dict):
update_to_v43(config_dict)
update_to_v50(config_dict)
def merge_config(config_dict, template_dict):
"""Merge the template (distribution) dictionary into the user's dictionary.
@@ -703,7 +705,7 @@ def update_to_v36(config_dict):
'et_period', 'wind_height', 'atc',
'nfac', 'max_delta_12h']:
config_dict['StdWXCalculate']['Calculations'][scalar] = \
config_dict['StdWXCalculate'][scalar]
config_dict['StdWXCalculate'][scalar]
config_dict['StdWXCalculate'].pop(scalar)
# Insert the old comment at the top of the new stanza:
try:
@@ -956,6 +958,19 @@ def update_to_v43(config_dict):
config_dict['version'] = '4.3.0'
def update_to_v50(config_dict):
"""Update a configuration file to V5.0
- If the config file uses '/' for WEEWX_ROOT, set it to '/etc/weewx'
"""
if 'WEEWX_ROOT' in config_dict and config_dict['WEEWX_ROOT'] == '/':
config_dict['WEEWX_ROOT'] = '/etc/weewx'
if 'WEEWX_ROOT_ORIG' in config_dict and config_dict['WEEWX_ROOT_ORIGIN'] == '/':
config_dict['WEEWX_ROOT_ORIG'] = '/etc/weewx'
config_dict['version'] = '5.0.0'
# ==============================================================================
# Various config sections
# ==============================================================================