diff --git a/analytics/management/commands/check_analytics_state.py b/analytics/management/commands/check_analytics_state.py index 6196dbace5..05eadc6111 100644 --- a/analytics/management/commands/check_analytics_state.py +++ b/analytics/management/commands/check_analytics_state.py @@ -3,12 +3,12 @@ import time from datetime import timedelta from typing import Any, Dict -from django.core.management.base import BaseCommand from django.utils.timezone import now as timezone_now from typing_extensions import override from analytics.lib.counts import ALL_COUNT_STATS, CountStat from analytics.models import installation_epoch +from zerver.lib.management import ZulipBaseCommand from zerver.lib.timestamp import TimeZoneNotUTCError, floor_to_day, floor_to_hour, verify_UTC from zerver.models import Realm @@ -20,7 +20,7 @@ states = { } -class Command(BaseCommand): +class Command(ZulipBaseCommand): help = """Checks FillState table. Run as a cron job that runs every hour.""" diff --git a/analytics/management/commands/clear_analytics_tables.py b/analytics/management/commands/clear_analytics_tables.py index 9292d94fc6..375bf5b744 100644 --- a/analytics/management/commands/clear_analytics_tables.py +++ b/analytics/management/commands/clear_analytics_tables.py @@ -1,13 +1,14 @@ from argparse import ArgumentParser from typing import Any -from django.core.management.base import BaseCommand, CommandError +from django.core.management.base import CommandError from typing_extensions import override from analytics.lib.counts import do_drop_all_analytics_tables +from zerver.lib.management import ZulipBaseCommand -class Command(BaseCommand): +class Command(ZulipBaseCommand): help = """Clear analytics tables.""" @override diff --git a/analytics/management/commands/clear_single_stat.py b/analytics/management/commands/clear_single_stat.py index be7da9debc..751f2ec987 100644 --- a/analytics/management/commands/clear_single_stat.py +++ b/analytics/management/commands/clear_single_stat.py @@ -1,13 +1,14 @@ from argparse import ArgumentParser from typing import Any -from django.core.management.base import BaseCommand, CommandError +from django.core.management.base import CommandError from typing_extensions import override from analytics.lib.counts import ALL_COUNT_STATS, do_drop_single_stat +from zerver.lib.management import ZulipBaseCommand -class Command(BaseCommand): +class Command(ZulipBaseCommand): help = """Clear analytics tables.""" @override diff --git a/analytics/management/commands/populate_analytics_db.py b/analytics/management/commands/populate_analytics_db.py index a50c756fd9..a93af40ecb 100644 --- a/analytics/management/commands/populate_analytics_db.py +++ b/analytics/management/commands/populate_analytics_db.py @@ -3,7 +3,6 @@ from datetime import timedelta from typing import Any, Dict, List, Mapping, Type, Union from django.core.files.uploadedfile import UploadedFile -from django.core.management.base import BaseCommand from django.utils.timezone import now as timezone_now from typing_extensions import TypeAlias, override @@ -21,6 +20,7 @@ from analytics.models import ( from zerver.actions.create_realm import do_create_realm from zerver.actions.users import do_change_user_role from zerver.lib.create_user import create_user +from zerver.lib.management import ZulipBaseCommand from zerver.lib.storage import static_path from zerver.lib.stream_color import STREAM_ASSIGNMENT_COLORS from zerver.lib.timestamp import floor_to_day @@ -38,7 +38,7 @@ from zerver.models import ( from zerver.models.groups import SystemGroups -class Command(BaseCommand): +class Command(ZulipBaseCommand): help = """Populates analytics tables with randomly generated data.""" DAYS_OF_DATA = 100 diff --git a/analytics/management/commands/update_analytics_counts.py b/analytics/management/commands/update_analytics_counts.py index 682aa520cc..2da50bc51c 100644 --- a/analytics/management/commands/update_analytics_counts.py +++ b/analytics/management/commands/update_analytics_counts.py @@ -5,19 +5,18 @@ from datetime import timezone from typing import Any, Dict from django.conf import settings -from django.core.management.base import BaseCommand from django.utils.dateparse import parse_datetime from django.utils.timezone import now as timezone_now from typing_extensions import override from analytics.lib.counts import ALL_COUNT_STATS, logger, process_count_stat -from zerver.lib.management import abort_unless_locked +from zerver.lib.management import ZulipBaseCommand, abort_unless_locked from zerver.lib.remote_server import send_server_data_to_push_bouncer from zerver.lib.timestamp import floor_to_hour from zerver.models import Realm -class Command(BaseCommand): +class Command(ZulipBaseCommand): help = """Fills Analytics tables. Run as a cron job that runs every hour.""" diff --git a/zerver/management/commands/archive_messages.py b/zerver/management/commands/archive_messages.py index c7f5569db3..ac38665048 100644 --- a/zerver/management/commands/archive_messages.py +++ b/zerver/management/commands/archive_messages.py @@ -1,13 +1,12 @@ from typing import Any -from django.core.management.base import BaseCommand from typing_extensions import override -from zerver.lib.management import abort_unless_locked +from zerver.lib.management import ZulipBaseCommand, abort_unless_locked from zerver.lib.retention import archive_messages, clean_archived_data -class Command(BaseCommand): +class Command(ZulipBaseCommand): @override @abort_unless_locked def handle(self, *args: Any, **options: str) -> None: diff --git a/zerver/management/commands/check_redis.py b/zerver/management/commands/check_redis.py index d15b6e678e..e500b1f8d0 100644 --- a/zerver/management/commands/check_redis.py +++ b/zerver/management/commands/check_redis.py @@ -3,15 +3,16 @@ import time from typing import Any, Callable, Optional from django.conf import settings -from django.core.management.base import BaseCommand, CommandError, CommandParser +from django.core.management.base import CommandError, CommandParser from typing_extensions import override +from zerver.lib.management import ZulipBaseCommand from zerver.lib.partial import partial from zerver.lib.rate_limiter import RateLimitedUser, client from zerver.models.users import get_user_profile_by_id -class Command(BaseCommand): +class Command(ZulipBaseCommand): help = """Checks Redis to make sure our rate limiting system hasn't grown a bug and left Redis with a bunch of data diff --git a/zerver/management/commands/checkconfig.py b/zerver/management/commands/checkconfig.py index 9e2f864334..93ae8f167f 100644 --- a/zerver/management/commands/checkconfig.py +++ b/zerver/management/commands/checkconfig.py @@ -1,12 +1,11 @@ from typing import Any -from django.core.management.base import BaseCommand from typing_extensions import override -from zerver.lib.management import check_config +from zerver.lib.management import ZulipBaseCommand, check_config -class Command(BaseCommand): +class Command(ZulipBaseCommand): help = """Checks /etc/zulip/settings.py for common configuration issues.""" @override diff --git a/zerver/management/commands/convert_mattermost_data.py b/zerver/management/commands/convert_mattermost_data.py index 17d29318fb..c28416838a 100644 --- a/zerver/management/commands/convert_mattermost_data.py +++ b/zerver/management/commands/convert_mattermost_data.py @@ -16,12 +16,13 @@ Test out the realm: go to browser and use your dev url """ -from django.core.management.base import BaseCommand, CommandError, CommandParser +from django.core.management.base import CommandError, CommandParser from zerver.data_import.mattermost import do_convert_data +from zerver.lib.management import ZulipBaseCommand -class Command(BaseCommand): +class Command(ZulipBaseCommand): help = """Convert the mattermost data into Zulip data format.""" @override diff --git a/zerver/management/commands/convert_rocketchat_data.py b/zerver/management/commands/convert_rocketchat_data.py index 2082434943..67a46cf686 100644 --- a/zerver/management/commands/convert_rocketchat_data.py +++ b/zerver/management/commands/convert_rocketchat_data.py @@ -2,13 +2,14 @@ import argparse import os from typing import Any -from django.core.management.base import BaseCommand, CommandError, CommandParser +from django.core.management.base import CommandError, CommandParser from typing_extensions import override from zerver.data_import.rocketchat import do_convert_data +from zerver.lib.management import ZulipBaseCommand -class Command(BaseCommand): +class Command(ZulipBaseCommand): help = """Convert the Rocketchat data into Zulip data format.""" @override diff --git a/zerver/management/commands/convert_slack_data.py b/zerver/management/commands/convert_slack_data.py index d8cb5b8838..a1117b05a5 100644 --- a/zerver/management/commands/convert_slack_data.py +++ b/zerver/management/commands/convert_slack_data.py @@ -4,13 +4,14 @@ import tempfile from typing import Any from django.conf import settings -from django.core.management.base import BaseCommand, CommandError, CommandParser +from django.core.management.base import CommandError, CommandParser from typing_extensions import override from zerver.data_import.slack import do_convert_data +from zerver.lib.management import ZulipBaseCommand -class Command(BaseCommand): +class Command(ZulipBaseCommand): help = """Convert the Slack data into Zulip data format.""" @override diff --git a/zerver/management/commands/create_realm_internal_bots.py b/zerver/management/commands/create_realm_internal_bots.py index a658c963a5..38b293eb13 100644 --- a/zerver/management/commands/create_realm_internal_bots.py +++ b/zerver/management/commands/create_realm_internal_bots.py @@ -1,12 +1,12 @@ from typing import Any -from django.core.management.base import BaseCommand from typing_extensions import override +from zerver.lib.management import ZulipBaseCommand from zerver.lib.onboarding import create_if_missing_realm_internal_bots -class Command(BaseCommand): +class Command(ZulipBaseCommand): help = """\ Create realm internal bots if absent, in all realms. diff --git a/zerver/management/commands/delete_old_unclaimed_attachments.py b/zerver/management/commands/delete_old_unclaimed_attachments.py index 745cb72d55..a83e81a7c3 100644 --- a/zerver/management/commands/delete_old_unclaimed_attachments.py +++ b/zerver/management/commands/delete_old_unclaimed_attachments.py @@ -2,18 +2,18 @@ from argparse import ArgumentParser from datetime import timedelta from typing import Any -from django.core.management.base import BaseCommand, CommandError +from django.core.management.base import CommandError from django.utils.timezone import now as timezone_now from typing_extensions import override from zerver.actions.uploads import do_delete_old_unclaimed_attachments from zerver.lib.attachments import get_old_unclaimed_attachments -from zerver.lib.management import abort_unless_locked +from zerver.lib.management import ZulipBaseCommand, abort_unless_locked from zerver.lib.upload import all_message_attachments, delete_message_attachments from zerver.models import ArchivedAttachment, Attachment -class Command(BaseCommand): +class Command(ZulipBaseCommand): help = """Remove unclaimed attachments from storage older than a supplied numerical value indicating the limit of how old the attachment can be. The default is five weeks.""" diff --git a/zerver/management/commands/deliver_scheduled_emails.py b/zerver/management/commands/deliver_scheduled_emails.py index ed8e548a01..66e1b44143 100644 --- a/zerver/management/commands/deliver_scheduled_emails.py +++ b/zerver/management/commands/deliver_scheduled_emails.py @@ -10,12 +10,12 @@ import time from typing import Any from django.conf import settings -from django.core.management.base import BaseCommand from django.db import transaction from django.utils.timezone import now as timezone_now from typing_extensions import override from zerver.lib.logging_util import log_to_file +from zerver.lib.management import ZulipBaseCommand from zerver.lib.send_email import EmailNotDeliveredError, deliver_scheduled_emails from zerver.models import ScheduledEmail @@ -24,7 +24,7 @@ logger = logging.getLogger(__name__) log_to_file(logger, settings.EMAIL_DELIVERER_LOG_PATH) -class Command(BaseCommand): +class Command(ZulipBaseCommand): help = """Send emails queued by various parts of Zulip for later delivery. diff --git a/zerver/management/commands/deliver_scheduled_messages.py b/zerver/management/commands/deliver_scheduled_messages.py index 1277deb19d..dc079047a6 100644 --- a/zerver/management/commands/deliver_scheduled_messages.py +++ b/zerver/management/commands/deliver_scheduled_messages.py @@ -4,19 +4,19 @@ from datetime import timedelta from typing import Any from django.conf import settings -from django.core.management.base import BaseCommand from django.utils.timezone import now as timezone_now from typing_extensions import override from zerver.actions.scheduled_messages import try_deliver_one_scheduled_message from zerver.lib.logging_util import log_to_file +from zerver.lib.management import ZulipBaseCommand ## Setup ## logger = logging.getLogger(__name__) log_to_file(logger, settings.DELIVER_SCHEDULED_MESSAGES_LOG_PATH) -class Command(BaseCommand): +class Command(ZulipBaseCommand): help = """Deliver scheduled messages from the ScheduledMessage table. Run this command under supervisor. diff --git a/zerver/management/commands/email_mirror.py b/zerver/management/commands/email_mirror.py index a436e9d834..70ba182db8 100644 --- a/zerver/management/commands/email_mirror.py +++ b/zerver/management/commands/email_mirror.py @@ -26,10 +26,11 @@ from imaplib import IMAP4_SSL from typing import Any, Generator from django.conf import settings -from django.core.management.base import BaseCommand, CommandError +from django.core.management.base import CommandError from typing_extensions import override from zerver.lib.email_mirror import logger, process_message +from zerver.lib.management import ZulipBaseCommand ## Setup ## @@ -79,7 +80,7 @@ def get_imap_messages() -> Generator[EmailMessage, None, None]: mbox.logout() -class Command(BaseCommand): +class Command(ZulipBaseCommand): help = __doc__ @override diff --git a/zerver/management/commands/enqueue_digest_emails.py b/zerver/management/commands/enqueue_digest_emails.py index 68cf7e3c55..c61ce31b57 100644 --- a/zerver/management/commands/enqueue_digest_emails.py +++ b/zerver/management/commands/enqueue_digest_emails.py @@ -3,20 +3,19 @@ from datetime import timedelta from typing import Any from django.conf import settings -from django.core.management.base import BaseCommand from django.utils.timezone import now as timezone_now from typing_extensions import override from zerver.lib.digest import DIGEST_CUTOFF, enqueue_emails from zerver.lib.logging_util import log_to_file -from zerver.lib.management import abort_unless_locked +from zerver.lib.management import ZulipBaseCommand, abort_unless_locked ## Logging setup ## logger = logging.getLogger(__name__) log_to_file(logger, settings.DIGEST_LOG_PATH) -class Command(BaseCommand): +class Command(ZulipBaseCommand): help = """Enqueue digest emails for users that haven't checked the app in a while. """ diff --git a/zerver/management/commands/enqueue_file.py b/zerver/management/commands/enqueue_file.py index 3c1efc0a8f..fae27ce423 100644 --- a/zerver/management/commands/enqueue_file.py +++ b/zerver/management/commands/enqueue_file.py @@ -3,9 +3,9 @@ from argparse import ArgumentParser from typing import IO, Any import orjson -from django.core.management.base import BaseCommand from typing_extensions import override +from zerver.lib.management import ZulipBaseCommand from zerver.lib.queue import queue_json_publish @@ -31,7 +31,7 @@ def enqueue_file(queue_name: str, f: IO[str]) -> None: queue_json_publish(queue_name, data, error) -class Command(BaseCommand): +class Command(ZulipBaseCommand): help = """Read JSON lines from a file and enqueue them to a worker queue. Each line in the file should either be a JSON payload or two tab-separated diff --git a/zerver/management/commands/export_usermessage_batch.py b/zerver/management/commands/export_usermessage_batch.py index a9c5907b83..1b9fd2dadd 100644 --- a/zerver/management/commands/export_usermessage_batch.py +++ b/zerver/management/commands/export_usermessage_batch.py @@ -4,13 +4,13 @@ import os from argparse import ArgumentParser from typing import Any -from django.core.management.base import BaseCommand from typing_extensions import override from zerver.lib.export import export_usermessages_batch +from zerver.lib.management import ZulipBaseCommand -class Command(BaseCommand): +class Command(ZulipBaseCommand): help = """UserMessage fetching helper for export.py""" @override diff --git a/zerver/management/commands/fill_memcached_caches.py b/zerver/management/commands/fill_memcached_caches.py index b9bb14f018..e4ae4046fc 100644 --- a/zerver/management/commands/fill_memcached_caches.py +++ b/zerver/management/commands/fill_memcached_caches.py @@ -1,13 +1,13 @@ from argparse import ArgumentParser from typing import Any, Optional -from django.core.management.base import BaseCommand from typing_extensions import override from zerver.lib.cache_helpers import cache_fillers, fill_remote_cache +from zerver.lib.management import ZulipBaseCommand -class Command(BaseCommand): +class Command(ZulipBaseCommand): @override def add_arguments(self, parser: ArgumentParser) -> None: parser.add_argument( diff --git a/zerver/management/commands/get_migration_status.py b/zerver/management/commands/get_migration_status.py index 95b153b693..9f04757f80 100644 --- a/zerver/management/commands/get_migration_status.py +++ b/zerver/management/commands/get_migration_status.py @@ -2,15 +2,15 @@ import argparse import os from typing import Any -from django.core.management.base import BaseCommand from django.db import DEFAULT_DB_ALIAS from typing_extensions import override from scripts.lib.zulip_tools import get_dev_uuid_var_path +from zerver.lib.management import ZulipBaseCommand from zerver.lib.test_fixtures import get_migration_status -class Command(BaseCommand): +class Command(ZulipBaseCommand): help = "Get status of migrations." @override diff --git a/zerver/management/commands/import.py b/zerver/management/commands/import.py index 0cf399da59..1a31fab57d 100644 --- a/zerver/management/commands/import.py +++ b/zerver/management/commands/import.py @@ -8,14 +8,15 @@ from typing import Any from django.conf import settings from django.core.exceptions import ValidationError from django.core.management import call_command -from django.core.management.base import BaseCommand, CommandError, CommandParser +from django.core.management.base import CommandError, CommandParser from typing_extensions import override from zerver.forms import OverridableValidationError, check_subdomain_available from zerver.lib.import_realm import do_import_realm +from zerver.lib.management import ZulipBaseCommand -class Command(BaseCommand): +class Command(ZulipBaseCommand): help = """Import extracted Zulip database dump directories into a fresh Zulip instance. This command should be used only on a newly created, empty Zulip instance to diff --git a/zerver/management/commands/process_queue.py b/zerver/management/commands/process_queue.py index 4041f3d9d2..be7d110b31 100644 --- a/zerver/management/commands/process_queue.py +++ b/zerver/management/commands/process_queue.py @@ -9,11 +9,12 @@ from types import FrameType from typing import Any, Iterator, List, Optional from django.conf import settings -from django.core.management.base import BaseCommand, CommandError +from django.core.management.base import CommandError from django.utils import autoreload from sentry_sdk import configure_scope from typing_extensions import override +from zerver.lib.management import ZulipBaseCommand from zerver.worker.queue_processors import get_active_worker_queues, get_worker @@ -33,7 +34,7 @@ def log_and_exit_if_exception( sys.exit(1) -class Command(BaseCommand): +class Command(ZulipBaseCommand): @override def add_arguments(self, parser: ArgumentParser) -> None: parser.add_argument("--queue_name", metavar="", help="queue to process") diff --git a/zerver/management/commands/purge_queue.py b/zerver/management/commands/purge_queue.py index 8b5c02d2da..15c190ff0b 100644 --- a/zerver/management/commands/purge_queue.py +++ b/zerver/management/commands/purge_queue.py @@ -2,14 +2,14 @@ from argparse import ArgumentParser from typing import Any from django.core.management import CommandError -from django.core.management.base import BaseCommand from typing_extensions import override +from zerver.lib.management import ZulipBaseCommand from zerver.lib.queue import SimpleQueueClient from zerver.worker.queue_processors import get_active_worker_queues -class Command(BaseCommand): +class Command(ZulipBaseCommand): @override def add_arguments(self, parser: ArgumentParser) -> None: parser.add_argument(dest="queue_name", nargs="?", help="queue to purge") diff --git a/zerver/management/commands/query_ldap.py b/zerver/management/commands/query_ldap.py index e251e1c1ca..24f4ee9f4f 100644 --- a/zerver/management/commands/query_ldap.py +++ b/zerver/management/commands/query_ldap.py @@ -1,13 +1,13 @@ from argparse import ArgumentParser from typing import Any -from django.core.management.base import BaseCommand from typing_extensions import override +from zerver.lib.management import ZulipBaseCommand from zproject.backends import query_ldap -class Command(BaseCommand): +class Command(ZulipBaseCommand): @override def add_arguments(self, parser: ArgumentParser) -> None: parser.add_argument("email", metavar="", help="email of user to query") diff --git a/zerver/management/commands/runtornado.py b/zerver/management/commands/runtornado.py index 2669498b8e..0f8c4dd1f4 100644 --- a/zerver/management/commands/runtornado.py +++ b/zerver/management/commands/runtornado.py @@ -7,10 +7,12 @@ from urllib.parse import SplitResult from asgiref.sync import async_to_sync, sync_to_async from django.conf import settings -from django.core.management.base import BaseCommand, CommandError, CommandParser +from django.core.management.base import CommandError, CommandParser from tornado.platform.asyncio import AsyncIOMainLoop from typing_extensions import override +from zerver.lib.management import ZulipBaseCommand + settings.RUNNING_INSIDE_TORNADO = True if settings.PRODUCTION: settings.SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https") @@ -34,7 +36,7 @@ if settings.USING_RABBITMQ: asyncio.set_event_loop_policy(NoAutoCreateEventLoopPolicy()) -class Command(BaseCommand): +class Command(ZulipBaseCommand): help = "Starts a Tornado Web server wrapping Django." @override diff --git a/zerver/management/commands/transfer_uploads_to_s3.py b/zerver/management/commands/transfer_uploads_to_s3.py index 6709964595..0bc1c8e963 100644 --- a/zerver/management/commands/transfer_uploads_to_s3.py +++ b/zerver/management/commands/transfer_uploads_to_s3.py @@ -1,13 +1,14 @@ from typing import Any from django.conf import settings -from django.core.management.base import BaseCommand, CommandError, CommandParser +from django.core.management.base import CommandError, CommandParser from typing_extensions import override +from zerver.lib.management import ZulipBaseCommand from zerver.lib.transfer import transfer_uploads_to_s3 -class Command(BaseCommand): +class Command(ZulipBaseCommand): help = """Transfer uploads to S3 """ @override diff --git a/zilencer/management/commands/add_mock_conversation.py b/zilencer/management/commands/add_mock_conversation.py index b424faaafb..548a25d8d4 100644 --- a/zilencer/management/commands/add_mock_conversation.py +++ b/zilencer/management/commands/add_mock_conversation.py @@ -1,6 +1,5 @@ from typing import Any, Dict, List -from django.core.management.base import BaseCommand from typing_extensions import override from zerver.actions.create_user import do_create_user @@ -9,13 +8,14 @@ from zerver.actions.reactions import do_add_reaction from zerver.actions.streams import bulk_add_subscriptions from zerver.actions.user_settings import do_change_avatar_fields from zerver.lib.emoji import get_emoji_data +from zerver.lib.management import ZulipBaseCommand from zerver.lib.streams import ensure_stream from zerver.lib.upload import upload_avatar_image from zerver.models import Message, UserProfile from zerver.models.realms import get_realm -class Command(BaseCommand): +class Command(ZulipBaseCommand): help = """Add a mock conversation to the development environment. Usage: ./manage.py add_mock_conversation diff --git a/zilencer/management/commands/add_server_to_legacy_plan.py b/zilencer/management/commands/add_server_to_legacy_plan.py index 1765eaec8c..2ed7b87a87 100644 --- a/zilencer/management/commands/add_server_to_legacy_plan.py +++ b/zilencer/management/commands/add_server_to_legacy_plan.py @@ -1,16 +1,17 @@ from datetime import datetime, timezone from typing import Any -from django.core.management.base import BaseCommand, CommandParser +from django.core.management.base import CommandParser from django.utils.timezone import now as timezone_now from typing_extensions import override from corporate.lib.stripe import RemoteServerBillingSession from scripts.lib.zulip_tools import TIMESTAMP_FORMAT +from zerver.lib.management import ZulipBaseCommand from zilencer.models import RemoteZulipServer -class Command(BaseCommand): +class Command(ZulipBaseCommand): help = "Assigns an existing RemoteZulipServer to the legacy plan" @override diff --git a/zilencer/management/commands/compare_messages.py b/zilencer/management/commands/compare_messages.py index 3c15aaf95b..3929a3ca2c 100644 --- a/zilencer/management/commands/compare_messages.py +++ b/zilencer/management/commands/compare_messages.py @@ -1,11 +1,13 @@ from typing import Any import orjson -from django.core.management.base import BaseCommand, CommandParser +from django.core.management.base import CommandParser from typing_extensions import override +from zerver.lib.management import ZulipBaseCommand -class Command(BaseCommand): + +class Command(ZulipBaseCommand): help = """ Compare rendered messages from files. Usage: ./manage.py compare_messages diff --git a/zilencer/management/commands/mark_all_messages_unread.py b/zilencer/management/commands/mark_all_messages_unread.py index 5008a77c25..7385084dff 100644 --- a/zilencer/management/commands/mark_all_messages_unread.py +++ b/zilencer/management/commands/mark_all_messages_unread.py @@ -3,14 +3,14 @@ from typing import Any import bmemcached from django.conf import settings from django.core.cache import cache -from django.core.management.base import BaseCommand from django.db.models import F from typing_extensions import override +from zerver.lib.management import ZulipBaseCommand from zerver.models import UserMessage -class Command(BaseCommand): +class Command(ZulipBaseCommand): help = """Script to mark all messages as unread.""" @override diff --git a/zilencer/management/commands/populate_billing_realms.py b/zilencer/management/commands/populate_billing_realms.py index 160a5864bc..931bf9ad46 100644 --- a/zilencer/management/commands/populate_billing_realms.py +++ b/zilencer/management/commands/populate_billing_realms.py @@ -6,7 +6,7 @@ from typing import Any, Dict, Optional import stripe from django.conf import settings -from django.core.management.base import BaseCommand, CommandParser +from django.core.management.base import CommandParser from django.utils.timezone import now as timezone_now from typing_extensions import override @@ -24,6 +24,7 @@ from zerver.actions.create_realm import do_create_realm from zerver.actions.create_user import do_create_user from zerver.actions.streams import bulk_add_subscriptions from zerver.apps import flush_cache +from zerver.lib.management import ZulipBaseCommand from zerver.lib.remote_server import get_realms_info_for_push_bouncer from zerver.lib.streams import create_stream_if_needed from zerver.models import Realm, UserProfile @@ -63,7 +64,7 @@ class CustomerProfile: remote_server_plan_start_date: str = "billing_cycle_end_date" -class Command(BaseCommand): +class Command(ZulipBaseCommand): help = "Populate database with different types of realms that can exist." @override diff --git a/zilencer/management/commands/populate_db.py b/zilencer/management/commands/populate_db.py index f58cd40d71..9e44e44e48 100644 --- a/zilencer/management/commands/populate_db.py +++ b/zilencer/management/commands/populate_db.py @@ -11,7 +11,7 @@ from django.conf import settings from django.contrib.sessions.models import Session from django.core.files.base import File from django.core.management import call_command -from django.core.management.base import BaseCommand, CommandParser +from django.core.management.base import CommandParser from django.core.validators import validate_email from django.db import connection from django.db.models import F @@ -36,6 +36,7 @@ from zerver.actions.user_settings import do_change_user_setting from zerver.actions.users import do_change_user_role from zerver.lib.bulk_create import bulk_create_streams from zerver.lib.generate_test_data import create_test_data, generate_topics +from zerver.lib.management import ZulipBaseCommand from zerver.lib.onboarding import create_if_missing_realm_internal_bots from zerver.lib.push_notifications import logger as push_notifications_logger from zerver.lib.remote_server import get_realms_info_for_push_bouncer @@ -201,7 +202,7 @@ def create_alert_words(realm_id: int) -> None: AlertWord.objects.bulk_create(recs) -class Command(BaseCommand): +class Command(ZulipBaseCommand): help = "Populate a test database" @override diff --git a/zilencer/management/commands/queue_rate.py b/zilencer/management/commands/queue_rate.py index c8c429d4b2..788a947070 100644 --- a/zilencer/management/commands/queue_rate.py +++ b/zilencer/management/commands/queue_rate.py @@ -2,14 +2,15 @@ import csv from timeit import timeit from typing import Any, Union -from django.core.management.base import BaseCommand, CommandParser +from django.core.management.base import CommandParser from typing_extensions import override +from zerver.lib.management import ZulipBaseCommand from zerver.lib.queue import SimpleQueueClient, queue_json_publish from zerver.worker.test import BatchNoopWorker, NoopWorker -class Command(BaseCommand): +class Command(ZulipBaseCommand): help = """Times the overhead of enqueuing and dequeuing messages from RabbitMQ.""" @override diff --git a/zilencer/management/commands/render_messages.py b/zilencer/management/commands/render_messages.py index efd556da7e..897c80c971 100644 --- a/zilencer/management/commands/render_messages.py +++ b/zilencer/management/commands/render_messages.py @@ -2,10 +2,11 @@ import os from typing import Any, Iterator import orjson -from django.core.management.base import BaseCommand, CommandParser +from django.core.management.base import CommandParser from django.db.models import QuerySet from typing_extensions import override +from zerver.lib.management import ZulipBaseCommand from zerver.lib.markdown import render_message_markdown from zerver.models import Message @@ -19,7 +20,7 @@ def queryset_iterator(queryset: QuerySet[Message], chunksize: int = 5000) -> Ite queryset = queryset.filter(id__gt=msg_id) -class Command(BaseCommand): +class Command(ZulipBaseCommand): help = """ Render messages to a file. Usage: ./manage.py render_messages [--amount=10000] diff --git a/zilencer/management/commands/sync_api_key.py b/zilencer/management/commands/sync_api_key.py index dbd1a042a2..a28c30e0d6 100644 --- a/zilencer/management/commands/sync_api_key.py +++ b/zilencer/management/commands/sync_api_key.py @@ -2,15 +2,15 @@ import os from configparser import ConfigParser from typing import Any -from django.core.management.base import BaseCommand from typing_extensions import override +from zerver.lib.management import ZulipBaseCommand from zerver.models import UserProfile from zerver.models.realms import get_realm from zerver.models.users import get_user_by_delivery_email -class Command(BaseCommand): +class Command(ZulipBaseCommand): help = """Sync your API key from ~/.zuliprc into your development instance""" @override