Get rid of no longer used common_parser

This commit is contained in:
Tom Keffer
2022-12-22 16:59:10 -08:00
parent fabd6f13f6
commit 4bb8a04abe
4 changed files with 11 additions and 10 deletions

View File

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

View File

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

View File

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

View File

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