From bd197886fe96f3c3246d036a9f59ae070273f206 Mon Sep 17 00:00:00 2001 From: Eeshan Garg Date: Thu, 20 Jan 2022 16:24:26 -0500 Subject: [PATCH] management/commands: Refactor logging code in register_server. --- zerver/management/commands/register_server.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/zerver/management/commands/register_server.py b/zerver/management/commands/register_server.py index 957bae4665..168a434e69 100644 --- a/zerver/management/commands/register_server.py +++ b/zerver/management/commands/register_server.py @@ -1,6 +1,6 @@ import subprocess from argparse import ArgumentParser -from typing import Any +from typing import Any, Dict import requests from django.conf import settings @@ -63,10 +63,7 @@ class Command(ZulipBaseCommand): if options["rotate_key"]: request["new_org_key"] = get_random_string(64) - print("The following data will be submitted to the push notification service:") - for key in sorted(request.keys()): - print(f" {key}: {request[key]}") - print("") + self._log_params(request) if not options["agree_to_terms_of_service"] and not options["rotate_key"]: print( @@ -120,3 +117,9 @@ class Command(ZulipBaseCommand): ] ) print("Mobile Push Notification Service registration successfully updated!") + + def _log_params(self, params: Dict[str, Any]) -> None: + print("The following data will be submitted to the push notification service:") + for key in sorted(params.keys()): + print(f" {key}: {params[key]}") + print("")