diff --git a/src/weecfg/__init__.py b/src/weecfg/__init__.py index d9456ab1..12f31492 100644 --- a/src/weecfg/__init__.py +++ b/src/weecfg/__init__.py @@ -156,19 +156,23 @@ def read_config(config_path, args=None, locations=DEFAULT_LOCATIONS, # Remember where we found the config file config_dict['config_path'] = os.path.realpath(config_path) - # If there was a value for WEEWX_ROOT in the configuration file, remember it so we can - # restore it later. - if 'WEEWX_ROOT' in config_dict: - config_dict['WEEWX_ROOT_CONFIG'] = config_dict['WEEWX_ROOT'] - # If WEEWX_ROOT is not in the configuration file, supply a default: - if 'WEEWX_ROOT' not in config_dict: + # Process WEEWX_ROOT + if 'WEEWX_ROOT' in config_dict: + # There is a value for WEEWX_ROOT. Save it. + config_dict['WEEWX_ROOT_CONFIG'] = config_dict['WEEWX_ROOT'] + # Check for an older config file. If found, patch to new location + if config_dict['WEEWX_ROOT'] == '/': + config_dict['WEEWX_ROOT'] = '/etc/weewx' + else: + # No WEEWX_ROOT in the config dictionary. Supply a default. config_dict['WEEWX_ROOT'] = os.path.dirname(config_path) - # In case WEEWX_ROOT is a relative path, join it with the location of the config file, then - # convert it to an absolute path. - config_dict['WEEWX_ROOT'] = os.path.abspath(os.path.join(os.path.dirname(config_path), - config_dict['WEEWX_ROOT'])) + # If the result of all that is not an absolute path, join it with the location of the config + # file, which will make it into an absolute path. + if not os.path.abspath(config_dict['WEEWX_ROOT']): + config_dict['WEEWX_ROOT'] = os.path.normpath(os.path.join(os.path.dirname(config_path), + config_dict['WEEWX_ROOT'])) return config_path, config_dict diff --git a/src/weecfg/extension.py b/src/weecfg/extension.py index 5db13d76..e569bd00 100644 --- a/src/weecfg/extension.py +++ b/src/weecfg/extension.py @@ -280,7 +280,7 @@ class ExtensionEngine(object): """Generate tuples of (source, destination) from a file_list""" # Go through all the files used by the extension. A "source tuple" is something like - # (bin, [user/myext.py, user/otherext.py]). + # (bin/user, [bin/user/myext.py, bin/user/otherext.py]). for source_tuple in file_list: # Expand the source tuple dest_dir, source_files = source_tuple diff --git a/src/weecfg/update_config.py b/src/weecfg/update_config.py index 115412e7..ca5839bc 100644 --- a/src/weecfg/update_config.py +++ b/src/weecfg/update_config.py @@ -558,6 +558,7 @@ def update_to_v32(config_dict): # with a trailing slash ('/'). Convert it to the normative form: if 'WEEWX_ROOT_CONFIG' in config_dict: config_dict['WEEWX_ROOT_CONFIG'] = os.path.normpath(config_dict['WEEWX_ROOT_CONFIG']) + config_dict['WEEWX_ROOT'] = os.path.normpath(config_dict['WEEWX_ROOT']) # Add a default database-specific top-level stanzas if necessary if 'DatabaseTypes' not in config_dict: