python: Sort migrations/management command imports with isort.

This is a preparatory commit for using isort for sorting all of our
imports, merging changes to files where we can easily review the
changes as something we're happy with.

These are also files with relatively little active development, which
means we don't expect much merge conflict risk from these changes.
This commit is contained in:
Tim Abbott 2020-01-14 12:59:46 -08:00
parent 9f8eccdbbf
commit 8e7ce7cc79
261 changed files with 356 additions and 223 deletions

View File

@ -8,6 +8,7 @@ from django.core.management.base import BaseCommand, CommandParser
from zerver.lib.timestamp import timestamp_to_datetime
from zerver.models import Message, Recipient
def compute_stats(log_level: int) -> None:
logger = logging.getLogger()
logger.setLevel(log_level)

View File

@ -7,6 +7,7 @@ from django.utils.timezone import utc
from zerver.lib.statistics import seconds_usage_between
from zerver.models import UserProfile
def analyze_activity(options: Dict[str, Any]) -> None:
day_start = datetime.datetime.strptime(options["date"], "%Y-%m-%d").replace(tzinfo=utc)
day_end = day_start + datetime.timedelta(days=options["duration"])

View File

@ -1,19 +1,17 @@
import os
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 analytics.models import installation_epoch, \
last_successful_fill
from analytics.lib.counts import COUNT_STATS, CountStat
from zerver.lib.timestamp import floor_to_hour, floor_to_day, verify_UTC, \
TimezoneNotUTCException
from analytics.models import installation_epoch, last_successful_fill
from zerver.lib.timestamp import TimezoneNotUTCException, floor_to_day, \
floor_to_hour, verify_UTC
from zerver.models import Realm
import os
import time
from typing import Any, Dict
states = {
0: "OK",
1: "WARNING",

View File

@ -5,6 +5,7 @@ from django.core.management.base import BaseCommand, CommandError
from analytics.lib.counts import do_drop_all_analytics_tables
class Command(BaseCommand):
help = """Clear analytics tables."""

View File

@ -5,6 +5,7 @@ from django.core.management.base import BaseCommand, CommandError
from analytics.lib.counts import COUNT_STATS, do_drop_single_stat
class Command(BaseCommand):
help = """Clear analytics tables."""

View File

@ -8,6 +8,7 @@ from django.utils.timezone import now as timezone_now
from zerver.lib.management import ZulipBaseCommand
from zerver.models import UserActivity
class Command(ZulipBaseCommand):
help = """Report rough client activity globally, for a realm, or for a user

View File

@ -1,21 +1,21 @@
from datetime import timedelta
from typing import Any, Dict, List, Mapping, Optional, Type
import mock
import mock
from django.core.management.base import BaseCommand
from django.utils.timezone import now as timezone_now
from analytics.lib.counts import COUNT_STATS, \
CountStat, do_drop_all_analytics_tables
from analytics.lib.counts import COUNT_STATS, CountStat, \
do_drop_all_analytics_tables
from analytics.lib.fixtures import generate_time_series_data
from analytics.lib.time_utils import time_range
from analytics.models import BaseCount, FillState, RealmCount, UserCount, \
StreamCount, InstallationCount
from zerver.lib.actions import do_change_is_admin, STREAM_ASSIGNMENT_COLORS
from analytics.models import BaseCount, FillState, InstallationCount, \
RealmCount, StreamCount, UserCount
from zerver.lib.actions import STREAM_ASSIGNMENT_COLORS, do_change_is_admin
from zerver.lib.create_user import create_user
from zerver.lib.timestamp import floor_to_day
from zerver.models import Realm, Stream, Client, \
Recipient, Subscription
from zerver.models import Client, Realm, Recipient, Stream, Subscription
class Command(BaseCommand):
help = """Populates analytics tables with randomly generated data."""

View File

@ -6,8 +6,8 @@ from django.core.management.base import BaseCommand, CommandError
from django.db.models import Count
from django.utils.timezone import now as timezone_now
from zerver.models import Message, Realm, Recipient, Stream, \
Subscription, UserActivity, UserMessage, UserProfile, get_realm
from zerver.models import Message, Realm, Recipient, Stream, Subscription, \
UserActivity, UserMessage, UserProfile, get_realm
MOBILE_CLIENT_LIST = ["Android", "ios"]
HUMAN_CLIENT_LIST = MOBILE_CLIENT_LIST + ["website"]

View File

@ -4,8 +4,9 @@ from typing import Any
from django.core.management.base import BaseCommand, CommandError
from django.db.models import Q
from zerver.models import Message, Realm, \
Recipient, Stream, Subscription, get_realm
from zerver.models import Message, Realm, Recipient, Stream, Subscription, \
get_realm
class Command(BaseCommand):
help = "Generate statistics on the streams for a realm."

View File

@ -15,6 +15,7 @@ from zerver.lib.remote_server import send_analytics_to_remote_server
from zerver.lib.timestamp import floor_to_hour
from zerver.models import Realm
class Command(BaseCommand):
help = """Fills Analytics tables.

View File

@ -7,6 +7,7 @@ from django.utils.timezone import now as timezone_now
from zerver.models import Message, Realm, Stream, UserProfile, get_realm
class Command(BaseCommand):
help = "Generate statistics on user activity."

View File

@ -3,6 +3,7 @@ import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [

View File

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [

View File

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [

View File

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [

View File

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [

View File

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [

View File

@ -2,6 +2,7 @@
# Generated by Django 1.10.4 on 2017-01-16 20:50
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [

View File

@ -2,6 +2,7 @@
# Generated by Django 1.10.5 on 2017-02-01 22:28
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [

View File

@ -3,6 +3,7 @@ from django.db import migrations
from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor
from django.db.migrations.state import StateApps
def delete_messages_sent_to_stream_stat(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:
UserCount = apps.get_model('analytics', 'UserCount')
StreamCount = apps.get_model('analytics', 'StreamCount')

View File

@ -3,6 +3,7 @@ from django.db import migrations
from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor
from django.db.migrations.state import StateApps
def clear_message_sent_by_message_type_values(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:
UserCount = apps.get_model('analytics', 'UserCount')
StreamCount = apps.get_model('analytics', 'StreamCount')

View File

@ -3,6 +3,7 @@ from django.db import migrations
from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor
from django.db.migrations.state import StateApps
def clear_analytics_tables(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:
UserCount = apps.get_model('analytics', 'UserCount')
StreamCount = apps.get_model('analytics', 'StreamCount')

View File

@ -2,8 +2,8 @@
# Generated by Django 1.11.6 on 2018-01-29 08:14
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):

View File

@ -2,8 +2,8 @@
# Generated by Django 1.11.14 on 2018-09-25 12:02
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):

View File

@ -2,8 +2,8 @@
# Generated by Django 1.11.16 on 2018-12-22 21:05
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):

View File

@ -2,8 +2,8 @@
# Generated by Django 1.11.18 on 2019-01-19 05:01
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):

View File

@ -2,8 +2,8 @@
# Generated by Django 1.11.18 on 2019-01-28 13:04
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from django.db import migrations
from django.conf import settings
from django.db import migrations
class Migration(migrations.Migration):

View File

@ -1,9 +1,11 @@
# -*- coding: utf-8 -*-
from django.db import migrations, connection
from django.db import connection, migrations
from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor
from django.db.migrations.state import StateApps
from zerver.lib.migrate import do_batch_update
def rebuild_pgroonga_index(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:
with connection.cursor() as cursor:
do_batch_update(cursor, 'zerver_message', ['search_pgroonga'],

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from django.db import migrations
from django.conf import settings
from django.db import migrations
class Migration(migrations.Migration):

View File

@ -10,6 +10,7 @@ from django.utils.timezone import now as timezone_now
from zerver.models import UserProfile
class Command(BaseCommand):
help = """Add users to a MailChimp mailing list."""

View File

@ -5,6 +5,7 @@ from django.core.management.base import CommandParser
from zerver.lib.actions import bulk_add_subscriptions, ensure_stream
from zerver.lib.management import ZulipBaseCommand
class Command(ZulipBaseCommand):
help = """Add some or all users in a realm to a set of streams."""

View File

@ -3,6 +3,7 @@ from __future__ import absolute_import
from typing import Any
from django.core.management.base import BaseCommand
from zerver.lib.retention import archive_messages, clean_archived_data

View File

@ -8,7 +8,7 @@ from django.conf import settings
from django.db import connection
from django.utils.timezone import now as timezone_now
from scripts.lib.zulip_tools import parse_os_release, run, TIMESTAMP_FORMAT
from scripts.lib.zulip_tools import TIMESTAMP_FORMAT, parse_os_release, run
from version import ZULIP_VERSION
from zerver.lib.management import ZulipBaseCommand
from zerver.logging_handlers import try_git_describe

View File

@ -7,6 +7,7 @@ from zerver.lib.actions import do_mark_all_as_read
from zerver.lib.management import ZulipBaseCommand
from zerver.models import Message
class Command(ZulipBaseCommand):
help = """Bankrupt one or many users."""

View File

@ -6,6 +6,7 @@ from django.core.management.base import CommandError
from zerver.lib.actions import do_change_full_name
from zerver.lib.management import ZulipBaseCommand
class Command(ZulipBaseCommand):
help = """Change the names for many users."""

View File

@ -4,6 +4,7 @@ from typing import Any
from zerver.lib.actions import do_change_user_delivery_email
from zerver.lib.management import ZulipBaseCommand
class Command(ZulipBaseCommand):
help = """Change the email address for a user."""

View File

@ -3,12 +3,14 @@ import time
from typing import Any, Callable, Optional
from django.conf import settings
from django.core.management.base import BaseCommand, CommandParser, CommandError
from django.core.management.base import BaseCommand, CommandError, \
CommandParser
from zerver.lib.rate_limiter import RateLimitedUser, \
client, max_api_calls, max_api_window
from zerver.lib.rate_limiter import RateLimitedUser, client, max_api_calls, \
max_api_window
from zerver.models import get_user_profile_by_id
class Command(BaseCommand):
help = """Checks redis to make sure our rate limiting system hasn't grown a bug
and left redis with a bunch of data

View File

@ -4,6 +4,7 @@ from django.core.management.base import BaseCommand
from zerver.lib.management import check_config
class Command(BaseCommand):
help = """Checks your Zulip Voyager Django configuration for issues."""

View File

@ -1,11 +1,11 @@
import json
import os
import polib
import re
import ujson
from subprocess import CalledProcessError, check_output
from typing import Any, Dict, List
import polib
import ujson
from django.conf import settings
from django.conf.locale import LANG_INFO
from django.core.management.base import CommandParser
@ -14,6 +14,7 @@ from django.utils.translation.trans_real import to_language
from zerver.lib.i18n import with_language
class Command(compilemessages.Command):
def add_arguments(self, parser: CommandParser) -> None:

View File

@ -3,10 +3,12 @@ import os
import tempfile
from typing import Any
from django.core.management.base import BaseCommand, CommandParser, CommandError
from django.core.management.base import BaseCommand, CommandError, \
CommandParser
from zerver.data_import.gitter import do_convert_data
class Command(BaseCommand):
help = """Convert the Gitter data into Zulip data format."""

View File

@ -21,10 +21,12 @@ spec:
exporting-from-hipchat-server-or-data-center-for-data-portability-950821555.html
'''
from django.core.management.base import BaseCommand, CommandParser, CommandError
from django.core.management.base import BaseCommand, CommandError, \
CommandParser
from zerver.data_import.hipchat import do_convert_data
class Command(BaseCommand):
help = """Convert the Hipchat data into Zulip data format."""

View File

@ -14,10 +14,12 @@ Test out the realm:
go to browser and use your dev url
'''
from django.core.management.base import BaseCommand, CommandParser, CommandError
from django.core.management.base import BaseCommand, CommandError, \
CommandParser
from zerver.data_import.mattermost import do_convert_data
class Command(BaseCommand):
help = """Convert the mattermost data into Zulip data format."""

View File

@ -3,10 +3,12 @@ import os
import tempfile
from typing import Any
from django.core.management.base import BaseCommand, CommandParser, CommandError
from django.core.management.base import BaseCommand, CommandError, \
CommandParser
from zerver.data_import.slack import do_convert_data
class Command(BaseCommand):
help = """Convert the Slack data into Zulip data format."""

View File

@ -5,6 +5,7 @@ from zerver.lib.actions import ensure_stream
from zerver.lib.management import ZulipBaseCommand
from zerver.models import DefaultStreamGroup
class Command(ZulipBaseCommand):
help = """
Create default stream groups which the users can choose during sign up.

View File

@ -4,6 +4,7 @@ from django.db import connection
from zerver.lib.management import ZulipBaseCommand
def create_indexes() -> None:
# Creating concurrent indexes is kind of a pain with current versions
# of Django/postgres, because you will get this error with seemingly

View File

@ -4,6 +4,7 @@ from django.core.management.base import BaseCommand
from zerver.lib.onboarding import create_if_missing_realm_internal_bots
class Command(BaseCommand):
help = """\
Create realm internal bots if absent, in all realms.

View File

@ -4,6 +4,7 @@ from typing import Any
from zerver.lib.actions import create_stream_if_needed
from zerver.lib.management import ZulipBaseCommand
class Command(ZulipBaseCommand):
help = """Create a stream, and subscribe all active users (excluding bots).

View File

@ -12,6 +12,7 @@ from zerver.lib.initial_password import initial_password
from zerver.lib.management import ZulipBaseCommand
from zerver.models import email_to_username
class Command(ZulipBaseCommand):
help = """Create the specified user with a default initial password.

View File

@ -4,6 +4,7 @@ from typing import Any
from zerver.lib.actions import do_deactivate_realm
from zerver.lib.management import ZulipBaseCommand
class Command(ZulipBaseCommand):
help = """Script to deactivate a realm."""

View File

@ -2,10 +2,11 @@ from argparse import ArgumentParser
from typing import Any
from zerver.lib.actions import do_deactivate_user
from zerver.lib.management import ZulipBaseCommand, CommandError
from zerver.lib.management import CommandError, ZulipBaseCommand
from zerver.lib.sessions import user_sessions
from zerver.models import UserProfile
class Command(ZulipBaseCommand):
help = "Deactivate a user, including forcibly logging them out."

View File

@ -6,6 +6,7 @@ from django.core.management.base import BaseCommand, CommandError
from zerver.lib.actions import do_delete_old_unclaimed_attachments
from zerver.models import get_old_unclaimed_attachments
class Command(BaseCommand):
help = """Remove unclaimed attachments from storage older than a supplied
numerical value indicating the limit of how old the attachment can be.

View File

@ -7,7 +7,6 @@ machines, as you may encounter multiple sends in a specific race
condition. (Alternatively, you can set `EMAIL_DELIVERER_DISABLED=True`
on all but one machine to make the command have no effect.)
"""
import logging
import time
from typing import Any

View File

@ -1,17 +1,17 @@
import logging
import time
from typing import Any, Dict
from datetime import timedelta
from typing import Any, Dict
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 zerver.lib.actions import do_send_messages
from zerver.lib.logging_util import log_to_file
from zerver.lib.management import sleep_forever
from zerver.models import ScheduledMessage, Message, get_user_by_delivery_email
from zerver.lib.actions import do_send_messages
from zerver.models import Message, ScheduledMessage, get_user_by_delivery_email
## Setup ##
logger = logging.getLogger(__name__)

View File

@ -8,6 +8,7 @@ from django.utils.timezone import utc as timezone_utc
from zerver.lib.management import ZulipBaseCommand
from zerver.models import Message, Recipient, Stream
class Command(ZulipBaseCommand):
help = "Dump messages from public streams of a realm"

View File

@ -19,8 +19,6 @@ We extract and validate the target stream from information in the
recipient address and retrieve, forward, and archive the message.
"""
import email
import logging
from email.message import Message

View File

@ -7,6 +7,7 @@ from django.core.management.base import BaseCommand
from zerver.lib.queue import queue_json_publish
def error(*args: Any) -> None:
raise Exception('We cannot enqueue because settings.USING_RABBITMQ is False.')

View File

@ -5,10 +5,11 @@ from typing import Any
from django.core.management.base import CommandError
from zerver.lib.management import ZulipBaseCommand
from zerver.lib.export import export_realm_wrapper
from zerver.lib.management import ZulipBaseCommand
from zerver.models import Message, Reaction
class Command(ZulipBaseCommand):
help = """Exports all data from a Zulip realm

View File

@ -8,6 +8,7 @@ from typing import Any
from zerver.lib.export import do_export_user
from zerver.lib.management import ZulipBaseCommand
class Command(ZulipBaseCommand):
help = """Exports message data from a Zulip user

View File

@ -9,6 +9,7 @@ from django.core.management.base import BaseCommand
from zerver.lib.export import export_usermessages_batch
class Command(BaseCommand):
help = """UserMessage fetching helper for export.py"""

View File

@ -5,6 +5,7 @@ from django.core.management.base import BaseCommand
from zerver.lib.cache_helpers import cache_fillers, fill_remote_cache
class Command(BaseCommand):
def add_arguments(self, parser: ArgumentParser) -> None:
parser.add_argument('--cache', dest="cache", default=None,

View File

@ -5,7 +5,7 @@ from typing import Any, List, Optional
from django.db import connection
from zerver.lib.fix_unreads import fix
from zerver.lib.management import ZulipBaseCommand, CommandError
from zerver.lib.management import CommandError, ZulipBaseCommand
from zerver.models import Realm, UserProfile
logging.getLogger('zulip.fix_unreads').setLevel(logging.INFO)

View File

@ -5,8 +5,9 @@ from django.core.management.base import CommandError
from confirmation.models import Confirmation, create_confirmation_link
from zerver.lib.management import ZulipBaseCommand
from zerver.models import PreregistrationUser, email_allowed_for_realm, \
DomainNotAllowedForRealmError
from zerver.models import DomainNotAllowedForRealmError, PreregistrationUser, \
email_allowed_for_realm
class Command(ZulipBaseCommand):
help = "Generate activation links for users and print them to stdout."

View File

@ -1,9 +1,10 @@
from argparse import ArgumentParser
from typing import Any, List
from zerver.lib.actions import ensure_stream, do_create_multiuse_invite_link
from zerver.lib.actions import do_create_multiuse_invite_link, ensure_stream
from zerver.lib.management import ZulipBaseCommand
from zerver.models import Stream, PreregistrationUser
from zerver.models import PreregistrationUser, Stream
class Command(ZulipBaseCommand):
help = "Generates invite link that can be used for inviting multiple users"

View File

@ -3,9 +3,10 @@ from typing import Any
from django.db import ProgrammingError
from confirmation.models import generate_realm_creation_url
from zerver.lib.management import ZulipBaseCommand, CommandError
from zerver.lib.management import CommandError, ZulipBaseCommand
from zerver.models import Realm
class Command(ZulipBaseCommand):
help = """
Outputs a randomly generated, 1-time-use link for Organization creation.

View File

@ -9,6 +9,7 @@ from django.db import DEFAULT_DB_ALIAS
from scripts.lib.zulip_tools import get_dev_uuid_var_path
from zerver.lib.test_fixtures import get_migration_status
class Command(BaseCommand):
help = "Get status of migrations."

View File

@ -5,10 +5,12 @@ from typing import Any
from django.conf import settings
from django.core.management import call_command
from django.core.management.base import BaseCommand, CommandParser, CommandError
from django.core.management.base import BaseCommand, CommandError, \
CommandParser
from zerver.lib.import_realm import do_import_realm, do_import_system_bots
from zerver.forms import check_subdomain_available
from zerver.lib.import_realm import do_import_realm, do_import_system_bots
class Command(BaseCommand):
help = """Import extracted Zulip database dump directories into a fresh Zulip instance.

View File

@ -1,13 +1,13 @@
from argparse import ArgumentParser
from typing import Any, Iterable, Tuple, Optional
from typing import Any, Iterable, Optional, Tuple
from django.conf import settings
from django.core.management.base import BaseCommand
from zerver.lib.actions import do_change_is_admin
from zerver.lib.bulk_create import bulk_create_users
from zerver.models import Realm, UserProfile, \
email_to_username, get_client, get_system_bot
from zerver.models import Realm, UserProfile, email_to_username, get_client, \
get_system_bot
settings.TORNADO_SERVER = None

View File

@ -6,6 +6,7 @@ from django.core.management.base import CommandError
from zerver.lib.actions import do_change_is_admin
from zerver.lib.management import ZulipBaseCommand
class Command(ZulipBaseCommand):
help = """Give an existing user administrative permissions over their (own) Realm.

View File

@ -5,6 +5,7 @@ from typing import Any
from zerver.lib.management import ZulipBaseCommand
from zerver.models import Realm
class Command(ZulipBaseCommand):
help = """List realms in the server and it's configuration settings(optional).

View File

@ -5,6 +5,7 @@ from zerver.lib.management import ZulipBaseCommand
from zerver.lib.sessions import delete_all_deactivated_user_sessions, \
delete_all_user_sessions, delete_realm_user_sessions
class Command(ZulipBaseCommand):
help = "Log out all users."

View File

@ -28,7 +28,6 @@ Credit for the approach goes to:
http://stackoverflow.com/questions/2090717
"""
import glob
import json
import os

View File

@ -5,8 +5,9 @@ from zerver.lib.actions import bulk_add_subscriptions, \
bulk_remove_subscriptions, do_deactivate_stream
from zerver.lib.cache import cache_delete_many, to_dict_cache_key_id
from zerver.lib.management import ZulipBaseCommand
from zerver.models import Message, Subscription, \
get_stream, get_stream_recipient
from zerver.models import Message, Subscription, get_stream, \
get_stream_recipient
def bulk_delete_cache_keys(message_ids_to_clear: List[int]) -> None:
while len(message_ids_to_clear) > 0:

View File

@ -1,8 +1,6 @@
"""
Shows backlog count of ScheduledEmail
"""
from datetime import timedelta
from typing import Any
@ -11,6 +9,7 @@ from django.utils.timezone import now as timezone_now
from zerver.models import ScheduledEmail
class Command(BaseCommand):
help = """Shows backlog count of ScheduledEmail
(The number of currently overdue (by at least a minute) email jobs)

View File

@ -12,6 +12,7 @@ from django.utils import autoreload
from zerver.worker.queue_processors import get_active_worker_queues, get_worker
class Command(BaseCommand):
def add_arguments(self, parser: ArgumentParser) -> None:
parser.add_argument('--queue_name', metavar='<queue name>', type=str,

View File

@ -7,6 +7,7 @@ from django.core.management.base import BaseCommand
from zerver.lib.queue import SimpleQueueClient
from zerver.worker.queue_processors import get_active_worker_queues
class Command(BaseCommand):
def add_arguments(self, parser: ArgumentParser) -> None:
parser.add_argument(dest="queue_name", type=str, nargs='?',

View File

@ -5,6 +5,7 @@ from django.core.management.base import BaseCommand
from zproject.backends import query_ldap
class Command(BaseCommand):
def add_arguments(self, parser: ArgumentParser) -> None:
parser.add_argument('email', metavar='<email>', type=str,

View File

@ -1,11 +1,12 @@
from argparse import ArgumentParser
from typing import Any
from zerver.lib.management import ZulipBaseCommand, CommandError
from zerver.lib.rate_limiter import RateLimitedUser, \
block_access, unblock_access
from zerver.lib.management import CommandError, ZulipBaseCommand
from zerver.lib.rate_limiter import RateLimitedUser, block_access, \
unblock_access
from zerver.models import UserProfile, get_user_profile_by_api_key
class Command(ZulipBaseCommand):
help = """Manually block or unblock a user from accessing the API"""

View File

@ -4,6 +4,7 @@ from typing import Any
from zerver.lib.actions import do_reactivate_realm
from zerver.lib.management import ZulipBaseCommand
class Command(ZulipBaseCommand):
help = """Script to reactivate a deactivated realm."""

View File

@ -6,9 +6,10 @@ from django.core.exceptions import ValidationError
from django.db.utils import IntegrityError
from zerver.lib.domains import validate_domain
from zerver.lib.management import ZulipBaseCommand, CommandError
from zerver.lib.management import CommandError, ZulipBaseCommand
from zerver.models import RealmDomain, get_realm_domains
class Command(ZulipBaseCommand):
help = """Manage domains for the specified realm"""

View File

@ -3,9 +3,10 @@ from argparse import ArgumentParser
from typing import Any
from zerver.lib.actions import do_add_realm_filter, do_remove_realm_filter
from zerver.lib.management import ZulipBaseCommand, CommandError
from zerver.lib.management import CommandError, ZulipBaseCommand
from zerver.models import all_realm_filters
class Command(ZulipBaseCommand):
help = """Create a link filter rule for the specified realm.

View File

@ -1,9 +1,9 @@
from argparse import ArgumentParser
import json
import requests
import subprocess
from argparse import ArgumentParser
from typing import Any
import requests
from django.conf import settings
from django.core.management.base import CommandError
from django.utils.crypto import get_random_string

View File

@ -6,6 +6,7 @@ from zerver.lib.actions import bulk_remove_subscriptions
from zerver.lib.management import ZulipBaseCommand
from zerver.models import get_stream
class Command(ZulipBaseCommand):
help = """Remove some or all users in a realm from a stream."""

View File

@ -5,6 +5,7 @@ from zerver.lib.actions import do_rename_stream
from zerver.lib.management import ZulipBaseCommand
from zerver.models import get_stream
class Command(ZulipBaseCommand):
help = """Change the stream name for a realm."""

View File

@ -1,11 +1,12 @@
from typing import Any
from django.core.management.base import CommandParser
from zerver.lib.management import ZulipBaseCommand
from zerver.lib.retention import restore_all_data_from_archive, \
restore_data_from_archive_by_realm, restore_data_from_archive
restore_data_from_archive, restore_data_from_archive_by_realm
from zerver.models import ArchiveTransaction
from typing import Any
class Command(ZulipBaseCommand):
help = """

View File

@ -3,8 +3,8 @@ import sys
from typing import Any, Callable
from django.conf import settings
from django.core.management.base import BaseCommand, \
CommandError, CommandParser
from django.core.management.base import BaseCommand, CommandError, \
CommandParser
from tornado import ioloop
from tornado.log import app_log
@ -24,7 +24,8 @@ from zerver.tornado.application import create_tornado_application, \
from zerver.tornado.autoreload import start as zulip_autoreload_start
from zerver.tornado.event_queue import add_client_gc_hook, \
missedmessage_hook, process_notification, setup_event_queue
from zerver.tornado.sharding import notify_tornado_queue_name, tornado_return_queue_name
from zerver.tornado.sharding import notify_tornado_queue_name, \
tornado_return_queue_name
from zerver.tornado.socket import respond_send_message
if settings.USING_RABBITMQ:

View File

@ -4,6 +4,7 @@ from typing import Any
from zerver.lib.actions import do_scrub_realm
from zerver.lib.management import ZulipBaseCommand
class Command(ZulipBaseCommand):
help = """Script to scrub a deactivated realm."""

View File

@ -1,7 +1,6 @@
import hashlib
import shutil
import subprocess
from argparse import ArgumentParser
from typing import Any, Dict, List
@ -10,6 +9,7 @@ from zerver.lib.send_email import FromAddress, send_email
from zerver.models import UserProfile
from zerver.templatetags.app_filters import render_markdown_path
def send_custom_email(users: List[UserProfile], options: Dict[str, Any]) -> None:
"""
Can be used directly with from a management shell with

View File

@ -8,6 +8,7 @@ from zerver.lib.management import CommandError, ZulipBaseCommand
from zerver.lib.send_email import FromAddress, send_email
from zerver.models import UserProfile
class Command(ZulipBaseCommand):
help = """Send email to specified email address."""

View File

@ -1,10 +1,10 @@
from argparse import ArgumentParser
from zerver.lib.management import ZulipBaseCommand, CommandError
from zerver.lib.actions import do_send_realm_reactivation_email
from typing import Any
from zerver.lib.actions import do_send_realm_reactivation_email
from zerver.lib.management import CommandError, ZulipBaseCommand
class Command(ZulipBaseCommand):
help = """Sends realm reactivation email to admins"""

View File

@ -4,6 +4,7 @@ from typing import Any
from django.conf import settings
from django.core.management.base import BaseCommand
class Command(BaseCommand):
help = """Send some stats to statsd."""

View File

@ -7,6 +7,7 @@ from django.core.management.commands import sendtestemail
from zerver.lib.send_email import FromAddress
class Command(sendtestemail.Command):
def handle(self, *args: Any, **kwargs: str) -> None:
if settings.WARN_NO_EMAIL:

View File

@ -1,20 +1,17 @@
import os
import email
import ujson
import os
from email.message import Message
from email.mime.text import MIMEText
from typing import Dict, Optional
import ujson
from django.conf import settings
from django.core.management.base import CommandParser
from zerver.lib.email_mirror import mirror_email_message
from zerver.lib.email_mirror_helpers import encode_email_address
from zerver.lib.management import ZulipBaseCommand, CommandError
from zerver.models import Realm, get_stream, get_realm
from typing import Dict, Optional
from zerver.lib.management import CommandError, ZulipBaseCommand
from zerver.models import Realm, get_realm, get_stream
# This command loads an email from a specified file and sends it
# to the email mirror. Simple emails can be passed in a JSON file,

View File

@ -1,15 +1,16 @@
import os
import ujson
from typing import Union, Dict, Optional
from typing import Dict, Optional, Union
import ujson
from django.conf import settings
from django.core.management.base import CommandParser
from django.test import Client
from zerver.lib.management import ZulipBaseCommand, CommandError
from zerver.lib.management import CommandError, ZulipBaseCommand
from zerver.lib.webhooks.common import standardize_headers
from zerver.models import get_realm
class Command(ZulipBaseCommand):
help = """
Create webhook message based on given fixture

View File

@ -6,9 +6,10 @@ from django.core.management.base import CommandParser
from django.db import models
from zerver.lib import utils
from zerver.lib.management import ZulipBaseCommand, CommandError
from zerver.lib.management import CommandError, ZulipBaseCommand
from zerver.models import UserMessage
class Command(ZulipBaseCommand):
help = """Sets user message flags. Used internally by actions.py. Marks all
Expects a comma-delimited list of user message ids via stdin, and an EOF to terminate."""

View File

@ -3,6 +3,7 @@ from typing import Any
from zerver.lib.management import ZulipBaseCommand
class Command(ZulipBaseCommand):
help = """Show the admins in a realm."""

View File

@ -7,6 +7,7 @@ from zerver.lib.management import ZulipBaseCommand
from zerver.lib.topic_mutes import build_topic_mute_checker
from zerver.models import Recipient, Subscription, UserMessage, UserProfile
def get_unread_messages(user_profile: UserProfile) -> List[Dict[str, Any]]:
user_msgs = UserMessage.objects.filter(
user_profile=user_profile,

View File

@ -6,10 +6,11 @@ from django.conf import settings
from django.core.management.base import CommandError
from zerver.lib.management import ZulipBaseCommand
from zerver.lib.soft_deactivation import do_soft_activate_users, \
do_soft_deactivate_users, do_auto_soft_deactivate_users, logger
from zerver.lib.soft_deactivation import do_auto_soft_deactivate_users, \
do_soft_activate_users, do_soft_deactivate_users, logger
from zerver.models import Realm, UserProfile
def get_users_from_emails(emails: List[str],
filter_kwargs: Dict[str, Realm]) -> List[UserProfile]:
# Bug: Ideally, this would be case-insensitive like our other email queries.

View File

@ -1,10 +1,9 @@
import logging
from argparse import ArgumentParser
from typing import Any, List
from django.db import transaction
from django.conf import settings
from django.db import transaction
from zerver.lib.logging_util import log_to_file
from zerver.lib.management import ZulipBaseCommand

View File

@ -1,10 +1,12 @@
from typing import Any
from django.core.management.base import BaseCommand, CommandParser, CommandError
from django.conf import settings
from django.core.management.base import BaseCommand, CommandError, \
CommandParser
from zerver.lib.transfer import transfer_uploads_to_s3
class Command(BaseCommand):
help = """Transfer uploads to S3 """

Some files were not shown because too many files have changed in this diff Show More