From a9d52052f0ad953c054df02871054b581f4d9d68 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Fri, 7 Jul 2017 11:50:50 -0700 Subject: [PATCH] manage.py: Print CommandError exceptions cleanly. Django, by default, prints these exceptions as a giant traceback, which is really ugly and scary to sysadmins. We really just want to print the error message to stdout for convenient viewing by the user. --- manage.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/manage.py b/manage.py index c3fae5ac76..57f45b57a4 100755 --- a/manage.py +++ b/manage.py @@ -1,4 +1,7 @@ #!/usr/bin/env python +from __future__ import absolute_import +from __future__ import print_function + import os import sys import logging @@ -16,6 +19,7 @@ if __name__ == "__main__": os.environ.setdefault("PYTHONSTARTUP", os.path.join(BASE_DIR, "scripts/lib/pythonrc.py")) from django.conf import settings + from django.core.management.base import CommandError logger = logging.getLogger("zulip.management") subprocess.check_call([os.path.join(BASE_DIR, "scripts", "lib", "log-management-command"), @@ -26,4 +30,8 @@ if __name__ == "__main__": from django.core.management import execute_from_command_line - execute_from_command_line(sys.argv) + try: + execute_from_command_line(sys.argv) + except CommandError as e: + print(e, file=sys.stderr) + sys.exit(1)