mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
management: Refactor checkconfig code to live in library.
This makes it possible to call this from other management commands.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import sys
|
||||
|
||||
from argparse import ArgumentParser
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import MultipleObjectsReturned
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from typing import Any, Dict, Optional, Text, List
|
||||
@@ -16,6 +17,16 @@ def is_integer_string(val: str) -> bool:
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
def check_config() -> None:
|
||||
for (setting_name, default) in settings.REQUIRED_SETTINGS:
|
||||
try:
|
||||
if settings.__getattr__(setting_name) != default:
|
||||
continue
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
raise CommandError("Error: You must set %s in /etc/zulip/settings.py." % (setting_name,))
|
||||
|
||||
class ZulipBaseCommand(BaseCommand):
|
||||
def add_realm_args(self, parser: ArgumentParser, required: bool=False,
|
||||
help: Optional[str]=None) -> None:
|
||||
|
||||
Reference in New Issue
Block a user