From 80824e9399dc6aa26e9176087dc06efcfdbc31e8 Mon Sep 17 00:00:00 2001 From: Tom Keffer Date: Wed, 28 Dec 2022 14:12:45 -0800 Subject: [PATCH] Use read_config() to read weewx.conf --- bin/weecfg/__init__.py | 4 ++-- bin/weecfg/station_config.py | 9 +-------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/bin/weecfg/__init__.py b/bin/weecfg/__init__.py index d4d927a0..bd140425 100644 --- a/bin/weecfg/__init__.py +++ b/bin/weecfg/__init__.py @@ -51,9 +51,9 @@ class Logger(object): # ============================================================================== if sys.platform == "darwin": - DEFAULT_LOCATIONS = ['../..', default_weewx_root, '/etc/weewx', '/Users/Shared/weewx'] + DEFAULT_LOCATIONS = [default_weewx_root, '/etc/weewx', '/Users/Shared/weewx'] else: - DEFAULT_LOCATIONS = ['../..', default_weewx_root, '/etc/weewx', '/home/weewx'] + DEFAULT_LOCATIONS = [default_weewx_root, '/etc/weewx', '/home/weewx'] def find_file(file_path=None, args=None, locations=DEFAULT_LOCATIONS, diff --git a/bin/weecfg/station_config.py b/bin/weecfg/station_config.py index 5039d754..816618b1 100644 --- a/bin/weecfg/station_config.py +++ b/bin/weecfg/station_config.py @@ -55,17 +55,10 @@ def create_station(config_path, *args, **kwargs): def reconfigure_station(config_path, *args, **kwargs): "Reconfigure an existing station" - if not config_path: - config_path = weecfg.default_config_path + config_path, config_dict = weecfg.read_config(config_path) print(f"The configuration file {bcolors.BOLD}{config_path}{bcolors.ENDC} will be used.") - # Make sure the file exists - if not os.path.exists(config_path): - raise weewx.ViolatedPrecondition(f"The configuration file {config_path} does not exist") - - config_dict = configobj.ConfigObj(config_path, encoding='utf-8', file_error=True) - config_config(config_dict, *args, **kwargs) # Save the results with backup