Use read_config() to read weewx.conf

This commit is contained in:
Tom Keffer
2022-12-28 14:12:45 -08:00
parent 863ddc1c02
commit 80824e9399
2 changed files with 3 additions and 10 deletions

View File

@@ -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,

View File

@@ -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