From 4bb8a04abe29954342aed0381b7e3826bfa2daca Mon Sep 17 00:00:00 2001 From: Tom Keffer Date: Thu, 22 Dec 2022 16:59:10 -0800 Subject: [PATCH] Get rid of no longer used common_parser --- bin/weecfg/station_config.py | 6 ++++++ bin/weectl/__init__.py | 6 +++++- bin/weectl/daemon.py | 4 ---- bin/weectl/station.py | 5 ----- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/bin/weecfg/station_config.py b/bin/weecfg/station_config.py index 7ac38cae..86f6f334 100644 --- a/bin/weecfg/station_config.py +++ b/bin/weecfg/station_config.py @@ -16,11 +16,13 @@ import weecfg import weeutil.config import weeutil.weeutil import weewx +from weectl import default_config_path from weeutil.weeutil import to_float, to_bool log = logging.getLogger(__name__) + def create_station(config_path, *args, **kwargs): """Create a brand-new configuration file. @@ -28,6 +30,10 @@ def create_station(config_path, *args, **kwargs): retrieves the template config file from package resources and uses that. """ + if not config_path: + config_path = default_config_path + print(f"The configuration file will be created at \033[1m{config_path}\033[0m.") + # Make sure there is not already a configuration file at the designated location. if os.path.exists(config_path): raise weewx.ViolatedPrecondition(f"Config file {config_path} already exists") diff --git a/bin/weectl/__init__.py b/bin/weectl/__init__.py index 266fa716..79adcc56 100644 --- a/bin/weectl/__init__.py +++ b/bin/weectl/__init__.py @@ -4,8 +4,12 @@ # See the file LICENSE.txt for your rights. # """The 'weectl' package.""" +import sys -import argparse +if sys.platform == 'darwin': + default_config_path = '/Users/Shared/weewx/weewx.conf' +else: + default_config_path = '/home/weewx/weewx.conf' # This is a common parser used as a parent for the other parsers. common_parser = argparse.ArgumentParser(description="Common parser", add_help=False) diff --git a/bin/weectl/daemon.py b/bin/weectl/daemon.py index 9a60d2b6..3583db30 100644 --- a/bin/weectl/daemon.py +++ b/bin/weectl/daemon.py @@ -5,8 +5,6 @@ # """Entry point for the "daemon" subcommand.""" -from . import common_parser - daemon_install_usage = "weectl daemon install --type={sysv|systemd} [--config=CONFIG-PATH]" daemon_uninstall_usage = "weectl daemon uninstall --type={sysv|systemd} [--config=CONFIG-PATH]" @@ -23,7 +21,6 @@ def add_subparser(subparsers): # Action "install': action_install_parser = action_parser.add_parser("install", - parents=[common_parser], description="Install an appropriate system " "file to run weewxd as a daemon. " "You must specify the type of file " @@ -38,7 +35,6 @@ def add_subparser(subparsers): # Action "uninstall": action_uninstall_parser = action_parser.add_parser("uninstall", - parents=[common_parser], description="After uninstalling, weewxd will " "not run as a daemon.", usage=daemon_uninstall_usage, diff --git a/bin/weectl/station.py b/bin/weectl/station.py index 4467cf1f..b0e55caa 100644 --- a/bin/weectl/station.py +++ b/bin/weectl/station.py @@ -7,7 +7,6 @@ import sys import weewx -from . import common_parser import weecfg.station_config station_create_usage = """weectl station create [--config=CONFIG-PATH] @@ -45,7 +44,6 @@ def add_subparser(subparsers, # Action 'create' create_station_parser = action_parser.add_parser('create', - parents=[common_parser], description=CREATE_DESCRIPTION, usage=station_create_usage, help='Create a station config file') @@ -95,7 +93,6 @@ def add_subparser(subparsers, # Action 'reconfigure' reconfigure_station_parser = action_parser.add_parser('reconfigure', - parents=[common_parser], usage=station_reconfigure_usage, help='Reconfigure a station config file') reconfigure_station_parser.add_argument('--driver', @@ -103,13 +100,11 @@ def add_subparser(subparsers, # Action 'upgrade' upgrade_station_parser = action_parser.add_parser('upgrade', - parents=[common_parser], usage=station_upgrade_usage, help='Upgrade a station config file') # Action 'upgrade-skins' upgrade_skins_parser = action_parser.add_parser('upgrade-skins', - parents=[common_parser], usage=station_upgrade_skins_usage, help='Upgrade the skins')