From 380334e7359e36c41cebf1c68b8ba63f6126fe1a Mon Sep 17 00:00:00 2001 From: Bruce CHEN <805899926@qq.com> Date: Tue, 13 Aug 2024 17:36:39 +0800 Subject: [PATCH] # improve share.py --- server/docker/db/redis/deploy.yml | 8 ++++---- server/share.py | 10 ++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/server/docker/db/redis/deploy.yml b/server/docker/db/redis/deploy.yml index aca41b7c4..1000ce370 100644 --- a/server/docker/db/redis/deploy.yml +++ b/server/docker/db/redis/deploy.yml @@ -32,11 +32,11 @@ services: --requirepass {{ param_db_redis_password }} --appendonly yes --ignore-warnings ARM64-COW-BUG - redis-exporter: + redis-exporter-{{ param_db_redis_port }}: <<: *redis-exporter-common labels: <<: *traefik-exporter-label - container_name: redis-exporter + container_name: redis-exporter-{{ param_db_redis_port }} user: root expose: - "9121" @@ -67,11 +67,11 @@ services: --cluster-enabled yes --cluster-announce-ip {{ param_db_redis_cluster_ip }} {%- endfor %} - redis-exporter: + redis-exporter-{{ param_db_redis_cluster_start_port }}: <<: *redis-exporter-common labels: <<: *traefik-exporter-label - container_name: redis-exporter + container_name: redis-exporter-{{ param_db_redis_cluster_start_port }} user: root expose: - "9121" diff --git a/server/share.py b/server/share.py index d3ca46ffe..6419102e6 100644 --- a/server/share.py +++ b/server/share.py @@ -177,12 +177,10 @@ def _format_action_invocation(self, action: argparse.Action) -> str: return ', '.join(t.strip() for t in parts) def _get_default_metavar_for_optional(self, action: argparse.Action) -> str: - if action.type: - return action.type.__name__ + return action.type.__name__ if action.type and action.type.__name__ else str.__name__ def _get_default_metavar_for_positional(self, action: argparse.Action) -> str: - if action.type: - return action.type.__name__ + return action.type.__name__ if action.type and action.type.__name__ else str.__name__ class AbstractRole(metaclass=ABCMeta): @@ -255,7 +253,7 @@ def __init__(self, root_path: pathlib.Path, role_class: typing.Type[AbstractRole self.role_deep: int = role_deep self.arg_parser: argparse.ArgumentParser = argparse.ArgumentParser(formatter_class=ArgParseHelpFormatter, usage='%(prog)s [command] [options]') self.set_common_argument(self.arg_parser) - self.__command_parser = self.arg_parser.add_subparsers(title="commands", metavar="", dest="command") + self.__command_parser = self.arg_parser.add_subparsers(title="commands", metavar="", dest="command", required=True) self.__init_install_parser() self.__init_delete_parser() self.__init_build_parser() @@ -377,7 +375,7 @@ def __loop_namespaces(self, namespaces: list[Namespace], global_env: dict, args: _rules = regex_util.match_rules([*jinja2ignore_rules], t.as_posix(), ".jinja2ignore {0}".format(self.__loop_namespaces.__name__)) role_output_file = role_output_path.joinpath(t.relative_to(role_path)) if not any(_rules.values()): - file_util.write_text(role_output_file, template_util.Template(file_util.read_text(t)).render(**role_env),t.stat().st_mode) + file_util.write_text(role_output_file, template_util.Template(file_util.read_text(t)).render(**role_env), t.stat().st_mode) else: file_util.copy(t, role_output_file)