From 80590a646b8014629491888c3cd02a8b76f70c56 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Mon, 1 Oct 2018 15:50:48 +0200 Subject: [PATCH 1/2] django-admin.py users: initialize log_msg --- nsupdate/management/commands/users.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nsupdate/management/commands/users.py b/nsupdate/management/commands/users.py index 9ed1c60..294b76c 100644 --- a/nsupdate/management/commands/users.py +++ b/nsupdate/management/commands/users.py @@ -77,6 +77,7 @@ class Command(BaseCommand): print_stats("before") for u in User.objects.all(): user = "%s <%s>" % (u.username, u.email) + log_msg = None if stale_check: log_msg = check_staleness(u) if log_msg: From 92211b040227299f67fb4b9340360609b053f7dc Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Mon, 1 Oct 2018 15:52:49 +0200 Subject: [PATCH 2/2] django-admin.py users: avoid unicode issues by using %r, fixes #350 non-ascii user names crashed the log output. --- nsupdate/management/commands/users.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nsupdate/management/commands/users.py b/nsupdate/management/commands/users.py index 294b76c..96a9420 100644 --- a/nsupdate/management/commands/users.py +++ b/nsupdate/management/commands/users.py @@ -17,10 +17,10 @@ T_age = 365 * DAY # min. age of last login for considering deletion of a user NEVER = datetime.fromtimestamp(DAY, timezone.utc) # 2.1.1970 -LOG_MSG_DELETE = _("%%(user)s hasn't logged in for %(age)fy, has no hosts and no domains -> deleted user.") -LOG_MSG_HAS_HOSTS = _("%%(user)s kept, has hosts. age: %(age)fy, hosts: %(hosts)d.") -LOG_MSG_HAS_DOMAINS = _("%%(user)s kept, has domains. age: %(age)fy, hosts: %(hosts)d, domains: %(domains)d.") -LOG_MSG_RECENTLY_USED = _("%(user)s kept, was used recently.") +LOG_MSG_DELETE = _("%%(user)r hasn't logged in for %(age)fy, has no hosts and no domains -> deleted user.") +LOG_MSG_HAS_HOSTS = _("%%(user)r kept, has hosts. age: %(age)fy, hosts: %(hosts)d.") +LOG_MSG_HAS_DOMAINS = _("%%(user)r kept, has domains. age: %(age)fy, hosts: %(hosts)d, domains: %(domains)d.") +LOG_MSG_RECENTLY_USED = _("%(user)r kept, was used recently.") def check_staleness(u):