mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
Django 1.10: Use add_argument for options in BaseCommand.
This commit is contained in:
@@ -6,15 +6,16 @@ import pytz
|
||||
|
||||
from optparse import make_option
|
||||
from typing import Any
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.core.management.base import BaseCommand, CommandParser
|
||||
from zerver.lib.statistics import activity_averages_during_day
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Generate statistics on user activity for a given day."
|
||||
|
||||
option_list = BaseCommand.option_list + \
|
||||
(make_option('--date', default=None, action='store',
|
||||
help="Day to query in format 2013-12-05. Default is yesterday"),)
|
||||
def add_arguments(self, parser):
|
||||
# type: (CommandParser) -> None
|
||||
parser.add_argument('--date', default=None, action='store',
|
||||
help="Day to query in format 2013-12-05. Default is yesterday")
|
||||
|
||||
def handle(self, *args, **options):
|
||||
# type: (*Any, **Any) -> None
|
||||
|
||||
@@ -4,7 +4,7 @@ from __future__ import print_function
|
||||
from typing import Any
|
||||
|
||||
from optparse import make_option
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.core.management.base import BaseCommand, CommandParser
|
||||
from zerver.models import Recipient, Message
|
||||
from zerver.lib.timestamp import timestamp_to_datetime
|
||||
import datetime
|
||||
@@ -73,11 +73,12 @@ def compute_stats(log_level):
|
||||
logging.info("%15s | %s%%" % (client, round(100. * total_counts[client] / grand_total, 1)))
|
||||
|
||||
class Command(BaseCommand):
|
||||
option_list = BaseCommand.option_list + \
|
||||
(make_option('--verbose', default=False, action='store_true'),)
|
||||
|
||||
help = "Compute statistics on MIT Zephyr usage."
|
||||
|
||||
def add_arguments(self, parser):
|
||||
# type: (CommandParser) -> None
|
||||
parser.add_argument('--verbose', default=False, action='store_true')
|
||||
|
||||
def handle(self, *args, **options):
|
||||
# type: (*Any, **Any) -> None
|
||||
level = logging.INFO
|
||||
|
||||
@@ -7,7 +7,7 @@ from typing import Any, Dict
|
||||
from zerver.lib.statistics import seconds_usage_between
|
||||
|
||||
from optparse import make_option
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.core.management.base import BaseCommand, CommandParser
|
||||
from zerver.models import UserProfile
|
||||
import datetime
|
||||
from django.utils.timezone import utc
|
||||
@@ -52,12 +52,12 @@ Usage: python manage.py analyze_user_activity [--realm=zulip.com] [--date=2013-0
|
||||
By default, if no date is selected 2013-09-10 is used. If no realm is provided, information
|
||||
is shown for all realms"""
|
||||
|
||||
option_list = BaseCommand.option_list + (
|
||||
make_option('--realm', action='store'),
|
||||
make_option('--date', action='store', default="2013-09-06"),
|
||||
make_option('--duration', action='store', default=1, type=int,
|
||||
help="How many days to show usage information for"),
|
||||
)
|
||||
def add_arguments(self, parser):
|
||||
# type: (CommandParser) -> None
|
||||
parser.add_argument('--realm', action='store')
|
||||
parser.add_argument('--date', action='store', default="2013-09-06")
|
||||
parser.add_argument('--duration', action='store', default=1, type=int,
|
||||
help="How many days to show usage information for")
|
||||
|
||||
def handle(self, *args, **options):
|
||||
# type: (*Any, **Any) -> None
|
||||
|
||||
@@ -5,7 +5,7 @@ from optparse import make_option
|
||||
|
||||
from typing import Any
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.core.management.base import BaseCommand, CommandParser
|
||||
|
||||
from zerver.lib.actions import create_stream_if_needed, bulk_add_subscriptions
|
||||
from zerver.models import UserProfile, get_realm, get_user_profile_by_email
|
||||
@@ -13,25 +13,32 @@ from zerver.models import UserProfile, get_realm, get_user_profile_by_email
|
||||
class Command(BaseCommand):
|
||||
help = """Add some or all users in a realm to a set of streams."""
|
||||
|
||||
option_list = BaseCommand.option_list + (
|
||||
make_option('-d', '--domain',
|
||||
dest='domain',
|
||||
type='str',
|
||||
help='The name of the realm in which you are adding people to streams.'),
|
||||
make_option('-s', '--streams',
|
||||
dest='streams',
|
||||
type='str',
|
||||
help='A comma-separated list of stream names.'),
|
||||
make_option('-u', '--users',
|
||||
dest='users',
|
||||
type='str',
|
||||
help='A comma-separated list of email addresses.'),
|
||||
make_option('-a', '--all-users',
|
||||
dest='all_users',
|
||||
action="store_true",
|
||||
default=False,
|
||||
help='Add all users in this realm to these streams.'),
|
||||
)
|
||||
def add_arguments(self, parser):
|
||||
# type: (CommandParser) -> None
|
||||
parser.add_argument(
|
||||
'-d', '--domain',
|
||||
dest='domain',
|
||||
type=str,
|
||||
help='The name of the realm in which you are adding people to streams.')
|
||||
|
||||
parser.add_argument(
|
||||
'-s', '--streams',
|
||||
dest='streams',
|
||||
type=str,
|
||||
help='A comma-separated list of stream names.')
|
||||
|
||||
parser.add_argument(
|
||||
'-u', '--users',
|
||||
dest='users',
|
||||
type=str,
|
||||
help='A comma-separated list of email addresses.')
|
||||
|
||||
parser.add_argument(
|
||||
'-a', '--all-users',
|
||||
dest='all_users',
|
||||
action="store_true",
|
||||
default=False,
|
||||
help='Add all users in this realm to these streams.')
|
||||
|
||||
def handle(self, **options):
|
||||
# type: (**Any) -> None
|
||||
|
||||
@@ -6,7 +6,7 @@ from typing import Any, Callable, Optional
|
||||
from zerver.models import get_user_profile_by_id
|
||||
from zerver.lib.rate_limiter import client, max_api_calls, max_api_window
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.core.management.base import BaseCommand, CommandParser
|
||||
from django.conf import settings
|
||||
from optparse import make_option
|
||||
|
||||
@@ -17,13 +17,13 @@ class Command(BaseCommand):
|
||||
|
||||
Usage: ./manage.py [--trim] check_redis"""
|
||||
|
||||
option_list = BaseCommand.option_list + (
|
||||
make_option('-t', '--trim',
|
||||
dest='trim',
|
||||
default=False,
|
||||
action='store_true',
|
||||
help="Actually trim excess"),
|
||||
)
|
||||
def add_arguments(self, parser):
|
||||
# type: (CommandParser) -> None
|
||||
parser.add_argument('-t', '--trim',
|
||||
dest='trim',
|
||||
default=False,
|
||||
action='store_true',
|
||||
help="Actually trim excess")
|
||||
|
||||
def _check_within_range(self, key, count_func, trim_func=None):
|
||||
# type: (str, Callable[[], int], Optional[Callable[[str, int], None]]) -> None
|
||||
|
||||
@@ -11,7 +11,6 @@ import sys
|
||||
class Command(BaseCommand):
|
||||
help = """Checks your Zulip Voyager Django configuration for issues."""
|
||||
|
||||
option_list = BaseCommand.option_list + ()
|
||||
def handle(self, *args, **options):
|
||||
# type: (*Any, **Any) -> None
|
||||
for (setting_name, default) in settings.REQUIRED_SETTINGS:
|
||||
|
||||
@@ -5,7 +5,7 @@ from optparse import make_option
|
||||
from typing import Any
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.core.management.base import BaseCommand, CommandParser
|
||||
from zerver.lib.actions import Realm, do_create_realm, set_default_streams
|
||||
from zerver.models import RealmAlias, can_add_alias, get_realm_by_string_id
|
||||
|
||||
@@ -20,36 +20,44 @@ class Command(BaseCommand):
|
||||
|
||||
Usage: python manage.py create_realm --string_id=acme --name='Acme'"""
|
||||
|
||||
option_list = BaseCommand.option_list + (
|
||||
make_option('-d', '--domain',
|
||||
dest='domain',
|
||||
type='str',
|
||||
help='The domain for the realm.'),
|
||||
make_option('-s', '--string_id',
|
||||
dest='string_id',
|
||||
type='str',
|
||||
help="A short name for the realm. If this installation uses subdomains, this will be used as the realm's subdomain."),
|
||||
make_option('-n', '--name',
|
||||
dest='name',
|
||||
type='str',
|
||||
help='The user-visible name for the realm.'),
|
||||
make_option('--corporate',
|
||||
dest='org_type',
|
||||
action="store_const",
|
||||
const=Realm.CORPORATE,
|
||||
help='Is a corporate org_type'),
|
||||
make_option('--community',
|
||||
dest='org_type',
|
||||
action="store_const",
|
||||
const=Realm.COMMUNITY,
|
||||
default=None,
|
||||
help='Is a community org_type. Is the default.'),
|
||||
make_option('--deployment',
|
||||
dest='deployment_id',
|
||||
type='int',
|
||||
default=None,
|
||||
help='Optionally, the ID of the deployment you want to associate the realm with.'),
|
||||
)
|
||||
def add_arguments(self, parser):
|
||||
# type: (CommandParser) -> None
|
||||
parser.add_argument('-d', '--domain',
|
||||
dest='domain',
|
||||
type=str,
|
||||
help='The domain for the realm.')
|
||||
|
||||
parser.add_argument('-s', '--string_id',
|
||||
dest='string_id',
|
||||
type=str,
|
||||
help="A short name for the realm. If this "
|
||||
"installation uses subdomains, this will be "
|
||||
"used as the realm's subdomain.")
|
||||
|
||||
parser.add_argument('-n', '--name',
|
||||
dest='name',
|
||||
type=str,
|
||||
help='The user-visible name for the realm.')
|
||||
|
||||
parser.add_argument('--corporate',
|
||||
dest='org_type',
|
||||
action="store_const",
|
||||
const=Realm.CORPORATE,
|
||||
help='Is a corporate org_type')
|
||||
|
||||
parser.add_argument('--community',
|
||||
dest='org_type',
|
||||
action="store_const",
|
||||
const=Realm.COMMUNITY,
|
||||
default=None,
|
||||
help='Is a community org_type. Is the default.')
|
||||
|
||||
parser.add_argument('--deployment',
|
||||
dest='deployment_id',
|
||||
type=int,
|
||||
default=None,
|
||||
help='Optionally, the ID of the deployment you '
|
||||
'want to associate the realm with.')
|
||||
|
||||
def validate_domain(self, domain):
|
||||
# type: (str) -> None
|
||||
|
||||
@@ -4,26 +4,26 @@ from __future__ import print_function
|
||||
from typing import Any
|
||||
|
||||
from optparse import make_option
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.core.management.base import BaseCommand, CommandParser
|
||||
from zerver.models import get_realm, Message, Realm, Stream, Recipient
|
||||
|
||||
import datetime
|
||||
import time
|
||||
|
||||
class Command(BaseCommand):
|
||||
default_cutoff = time.time() - 60 * 60 * 24 * 30 # 30 days.
|
||||
def add_arguments(self, parser):
|
||||
# type: (CommandParser) -> None
|
||||
default_cutoff = time.time() - 60 * 60 * 24 * 30 # 30 days.
|
||||
parser.add_argument('--domain',
|
||||
dest='domain',
|
||||
type=str,
|
||||
help='The domain whose public streams you want to dump.')
|
||||
|
||||
option_list = BaseCommand.option_list + (
|
||||
make_option('--domain',
|
||||
dest='domain',
|
||||
type='str',
|
||||
help='The domain whose public streams you want to dump.'),
|
||||
make_option('--since',
|
||||
dest='since',
|
||||
type='int',
|
||||
default=default_cutoff,
|
||||
help='The time in epoch since from which to start the dump.')
|
||||
)
|
||||
parser.add_argument('--since',
|
||||
dest='since',
|
||||
type=int,
|
||||
default=default_cutoff,
|
||||
help='The time in epoch since from which to start the dump.')
|
||||
|
||||
def handle(self, *args, **options):
|
||||
# type: (*Any, **Any) -> None
|
||||
|
||||
@@ -4,7 +4,7 @@ from __future__ import print_function
|
||||
from optparse import make_option
|
||||
|
||||
from django.core.management import call_command
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.core.management.base import BaseCommand, CommandParser
|
||||
from django.db import connection
|
||||
from django.conf import settings
|
||||
|
||||
@@ -29,18 +29,19 @@ import a database dump from one or more JSON files.
|
||||
|
||||
Usage: python2.7 manage.py import [--destroy-rebuild-database] [--import-into-nonempty] <export path name> [<export path name>...]"""
|
||||
|
||||
option_list = BaseCommand.option_list + (
|
||||
make_option('--destroy-rebuild-database',
|
||||
dest='destroy_rebuild_database',
|
||||
default=False,
|
||||
action="store_true",
|
||||
help='Destroys and rebuilds the databases prior to import.'),
|
||||
make_option('--import-into-nonempty',
|
||||
dest='import_into_nonempty',
|
||||
default=False,
|
||||
action="store_true",
|
||||
help='Import into an existing nonempty database.'),
|
||||
)
|
||||
def add_arguments(self, parser):
|
||||
# type: (CommandParser) -> None
|
||||
parser.add_argument('--destroy-rebuild-database',
|
||||
dest='destroy_rebuild_database',
|
||||
default=False,
|
||||
action="store_true",
|
||||
help='Destroys and rebuilds the databases prior to import.')
|
||||
|
||||
parser.add_argument('--import-into-nonempty',
|
||||
dest='import_into_nonempty',
|
||||
default=False,
|
||||
action="store_true",
|
||||
help='Import into an existing nonempty database.')
|
||||
|
||||
def new_instance_check(self, model):
|
||||
# type: (Model) -> None
|
||||
|
||||
@@ -6,7 +6,7 @@ from typing import Any
|
||||
from argparse import ArgumentParser
|
||||
from optparse import make_option
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.core.management.base import BaseCommand, CommandParser
|
||||
|
||||
from zerver.lib.actions import bulk_remove_subscriptions
|
||||
from zerver.models import Realm, UserProfile, get_realm, get_stream, \
|
||||
@@ -15,25 +15,29 @@ from zerver.models import Realm, UserProfile, get_realm, get_stream, \
|
||||
class Command(BaseCommand):
|
||||
help = """Remove some or all users in a realm from a stream."""
|
||||
|
||||
option_list = BaseCommand.option_list + (
|
||||
make_option('-d', '--domain',
|
||||
dest='domain',
|
||||
type='str',
|
||||
help='The name of the realm in which you are removing people.'),
|
||||
make_option('-s', '--stream',
|
||||
dest='stream',
|
||||
type='str',
|
||||
help='A stream name.'),
|
||||
make_option('-u', '--users',
|
||||
dest='users',
|
||||
type='str',
|
||||
help='A comma-separated list of email addresses.'),
|
||||
make_option('-a', '--all-users',
|
||||
dest='all_users',
|
||||
action="store_true",
|
||||
default=False,
|
||||
help='Remove all users in this realm from this stream.'),
|
||||
)
|
||||
def add_arguments(self, parser):
|
||||
# type: (CommandParser) -> None
|
||||
parser.add_argument('-d', '--domain',
|
||||
dest='domain',
|
||||
type=str,
|
||||
help='The name of the realm in which you are '
|
||||
'removing people.')
|
||||
|
||||
parser.add_argument('-s', '--stream',
|
||||
dest='stream',
|
||||
type=str,
|
||||
help='A stream name.')
|
||||
|
||||
parser.add_argument('-u', '--users',
|
||||
dest='users',
|
||||
type=str,
|
||||
help='A comma-separated list of email addresses.')
|
||||
|
||||
parser.add_argument('-a', '--all-users',
|
||||
dest='all_users',
|
||||
action="store_true",
|
||||
default=False,
|
||||
help='Remove all users in this realm from this stream.')
|
||||
|
||||
def handle(self, **options):
|
||||
# type: (*Any, **Any) -> None
|
||||
|
||||
@@ -13,7 +13,7 @@ settings.RUNNING_INSIDE_TORNADO = True
|
||||
from zerver.lib.tornado_ioloop_logging import instrument_tornado_ioloop
|
||||
instrument_tornado_ioloop()
|
||||
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from django.core.management.base import BaseCommand, CommandError, CommandParser
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from optparse import make_option
|
||||
import sys
|
||||
@@ -53,16 +53,21 @@ def handle_callback_exception(callback):
|
||||
app_log.error("Exception in callback %r", callback, exc_info=True)
|
||||
|
||||
class Command(BaseCommand):
|
||||
option_list = BaseCommand.option_list + (
|
||||
make_option('--nokeepalive', action='store_true',
|
||||
dest='no_keep_alive', default=False,
|
||||
help="Tells Tornado to NOT keep alive http connections."),
|
||||
make_option('--noxheaders', action='store_false',
|
||||
dest='xheaders', default=True,
|
||||
help="Tells Tornado to NOT override remote IP with X-Real-IP."),
|
||||
)
|
||||
help = "Starts a Tornado Web server wrapping Django."
|
||||
args = '[optional port number or ipaddr:port]\n (use multiple ports to start multiple servers)'
|
||||
|
||||
def add_arguments(self, parser):
|
||||
# type: (CommandParser) -> None
|
||||
parser.add_argument('addrport', nargs="?", type=str,
|
||||
help='[optional port number or ipaddr:port]\n '
|
||||
'(use multiple ports to start multiple servers)')
|
||||
|
||||
parser.add_argument('--nokeepalive', action='store_true',
|
||||
dest='no_keep_alive', default=False,
|
||||
help="Tells Tornado to NOT keep alive http connections.")
|
||||
|
||||
parser.add_argument('--noxheaders', action='store_false',
|
||||
dest='xheaders', default=True,
|
||||
help="Tells Tornado to NOT override remote IP with X-Real-IP.")
|
||||
|
||||
def handle(self, addrport, **options):
|
||||
# type: (str, **bool) -> None
|
||||
|
||||
@@ -9,7 +9,7 @@ from optparse import make_option
|
||||
|
||||
from django.test import Client
|
||||
from django.conf import settings
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.core.management.base import BaseCommand, CommandParser
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
@@ -22,16 +22,19 @@ Example:
|
||||
|
||||
"""
|
||||
|
||||
option_list = BaseCommand.option_list + (
|
||||
make_option('-f', '--fixture',
|
||||
dest='fixture',
|
||||
type='str',
|
||||
help='The path to the fixture you\'d like to send into Zulip'),
|
||||
make_option('-u', '--url',
|
||||
dest='url',
|
||||
type='str',
|
||||
help='The url on your Zulip server that you want to post the fixture to'),
|
||||
)
|
||||
def add_arguments(self, parser):
|
||||
# type: (CommandParser) -> None
|
||||
parser.add_argument('-f', '--fixture',
|
||||
dest='fixture',
|
||||
type=str,
|
||||
help='The path to the fixture you\'d like to send '
|
||||
'into Zulip')
|
||||
|
||||
parser.add_argument('-u', '--url',
|
||||
dest='url',
|
||||
type=str,
|
||||
help='The url on your Zulip server that you want '
|
||||
'to post the fixture to')
|
||||
|
||||
def handle(self, **options):
|
||||
# type: (*Any, **str) -> None
|
||||
|
||||
@@ -3,7 +3,7 @@ from __future__ import print_function
|
||||
|
||||
from typing import Any
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.core.management.base import BaseCommand, CommandParser
|
||||
|
||||
from zerver.models import get_realm
|
||||
from zerver.lib.actions import set_default_streams
|
||||
@@ -26,16 +26,18 @@ python manage.py set_default_streams --domain=foo.com --streams="foo,bar,baz wit
|
||||
python manage.py set_default_streams --domain=foo.com --streams=
|
||||
"""
|
||||
|
||||
option_list = BaseCommand.option_list + (
|
||||
make_option('-d', '--domain',
|
||||
dest='domain',
|
||||
type='str',
|
||||
help='The name of the existing realm to which to attach default streams.'),
|
||||
make_option('-s', '--streams',
|
||||
dest='streams',
|
||||
type='str',
|
||||
help='A comma-separated list of stream names.'),
|
||||
)
|
||||
def add_arguments(self, parser):
|
||||
# type: (CommandParser) -> None
|
||||
parser.add_argument('-d', '--domain',
|
||||
dest='domain',
|
||||
type=str,
|
||||
help='The name of the existing realm to which to '
|
||||
'attach default streams.')
|
||||
|
||||
parser.add_argument('-s', '--streams',
|
||||
dest='streams',
|
||||
type=str,
|
||||
help='A comma-separated list of stream names.')
|
||||
|
||||
def handle(self, **options):
|
||||
# type: (*Any, **str) -> None
|
||||
|
||||
@@ -7,7 +7,7 @@ from optparse import make_option
|
||||
import logging
|
||||
import sys
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.core.management.base import BaseCommand, CommandParser
|
||||
|
||||
from zerver.lib import utils
|
||||
from zerver.models import UserMessage, get_user_profile_by_email
|
||||
@@ -18,29 +18,33 @@ class Command(BaseCommand):
|
||||
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."""
|
||||
|
||||
option_list = BaseCommand.option_list + (
|
||||
make_option('-r', '--for-real',
|
||||
dest='for_real',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help="Actually change message flags. Default is a dry run."),
|
||||
make_option('-f', '--flag',
|
||||
dest='flag',
|
||||
type='string',
|
||||
help="The flag to add of remove"),
|
||||
make_option('-o', '--op',
|
||||
dest='op',
|
||||
type='string',
|
||||
help="The operation to do: 'add' or 'remove'"),
|
||||
make_option('-u', '--until',
|
||||
dest='all_until',
|
||||
type='string',
|
||||
help="Mark all messages <= specific usermessage id"),
|
||||
make_option('-m', '--email',
|
||||
dest='email',
|
||||
type='string',
|
||||
help="Email to set messages for"),
|
||||
)
|
||||
def add_arguments(self, parser):
|
||||
# type: (CommandParser) -> None
|
||||
parser.add_argument('-r', '--for-real',
|
||||
dest='for_real',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help="Actually change message flags. Default is a dry run.")
|
||||
|
||||
parser.add_argument('-f', '--flag',
|
||||
dest='flag',
|
||||
type=str,
|
||||
help="The flag to add of remove")
|
||||
|
||||
parser.add_argument('-o', '--op',
|
||||
dest='op',
|
||||
type=str,
|
||||
help="The operation to do: 'add' or 'remove'")
|
||||
|
||||
parser.add_argument('-u', '--until',
|
||||
dest='all_until',
|
||||
type=str,
|
||||
help="Mark all messages <= specific usermessage id")
|
||||
|
||||
parser.add_argument('-m', '--email',
|
||||
dest='email',
|
||||
type=str,
|
||||
help="Email to set messages for")
|
||||
|
||||
def handle(self, *args, **options):
|
||||
# type: (*Any, **Any) -> None
|
||||
|
||||
@@ -5,7 +5,7 @@ from typing import Any
|
||||
|
||||
from optparse import make_option
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.core.management.base import BaseCommand, CommandParser
|
||||
|
||||
from zerver.lib.actions import do_change_enable_digest_emails
|
||||
from zerver.models import Realm, UserProfile, get_realm, get_user_profile_by_email
|
||||
@@ -13,16 +13,18 @@ from zerver.models import Realm, UserProfile, get_realm, get_user_profile_by_ema
|
||||
class Command(BaseCommand):
|
||||
help = """Turn off digests for a domain or specified set of email addresses."""
|
||||
|
||||
option_list = BaseCommand.option_list + (
|
||||
make_option('-d', '--domain',
|
||||
dest='domain',
|
||||
type='str',
|
||||
help='Turn off digests for all users in this domain.'),
|
||||
make_option('-u', '--users',
|
||||
dest='users',
|
||||
type='str',
|
||||
help='Turn off digests for this comma-separated list of email addresses.'),
|
||||
)
|
||||
def add_arguments(self, parser):
|
||||
# type: (CommandParser) -> None
|
||||
parser.add_argument('-d', '--domain',
|
||||
dest='domain',
|
||||
type=str,
|
||||
help='Turn off digests for all users in this domain.')
|
||||
|
||||
parser.add_argument('-u', '--users',
|
||||
dest='users',
|
||||
type=str,
|
||||
help='Turn off digests for this comma-separated '
|
||||
'list of email addresses.')
|
||||
|
||||
def handle(self, **options):
|
||||
# type: (**str) -> None
|
||||
|
||||
@@ -5,7 +5,7 @@ from optparse import make_option
|
||||
import sys
|
||||
from typing import Any
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.core.management.base import BaseCommand, CommandParser
|
||||
|
||||
from zerver.models import get_realm
|
||||
from zerver.lib.create_user import random_api_key
|
||||
@@ -16,21 +16,18 @@ from zilencer.models import Deployment
|
||||
class Command(BaseCommand):
|
||||
help = """Create a deployment and accompanying realm."""
|
||||
|
||||
option_list = CreateRealm.option_list + (
|
||||
make_option('--no-realm',
|
||||
dest='no_realm',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help='Do not create a new realm; associate with an existing one.' + \
|
||||
' In this case, only the domain and URLs need to be specified.'),
|
||||
make_option('-a', '--api-url',
|
||||
dest='api',
|
||||
type='str'),
|
||||
make_option('-w', '--web-url',
|
||||
dest='web',
|
||||
type='str'),
|
||||
def add_arguments(self, parser):
|
||||
# type: (CommandParser) -> None
|
||||
parser.add_argument('--no-realm',
|
||||
dest='no_realm',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help='Do not create a new realm; associate with '
|
||||
'an existing one. In this case, only the '
|
||||
'domain and URLs need to be specified.')
|
||||
|
||||
)
|
||||
parser.add_argument('-a', '--api-url', dest='api', type=str)
|
||||
parser.add_argument('-w', '--web-url', dest='web', type=str)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
# type: (*Any, **Any) -> None
|
||||
|
||||
@@ -2,7 +2,7 @@ from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.core.management.base import BaseCommand, CommandParser
|
||||
from django.utils.timezone import now
|
||||
|
||||
from django.contrib.sites.models import Site
|
||||
@@ -55,62 +55,72 @@ def create_streams(realms, realm, stream_list):
|
||||
class Command(BaseCommand):
|
||||
help = "Populate a test database"
|
||||
|
||||
option_list = BaseCommand.option_list + (
|
||||
make_option('-n', '--num-messages',
|
||||
def add_arguments(self, parser):
|
||||
# type: (CommandParser) -> None
|
||||
parser.add_argument('-n', '--num-messages',
|
||||
dest='num_messages',
|
||||
type='int',
|
||||
type=int,
|
||||
default=600,
|
||||
help='The number of messages to create.'),
|
||||
make_option('--extra-users',
|
||||
help='The number of messages to create.')
|
||||
|
||||
parser.add_argument('--extra-users',
|
||||
dest='extra_users',
|
||||
type='int',
|
||||
type=int,
|
||||
default=0,
|
||||
help='The number of extra users to create'),
|
||||
make_option('--huddles',
|
||||
help='The number of extra users to create')
|
||||
|
||||
parser.add_argument('--huddles',
|
||||
dest='num_huddles',
|
||||
type='int',
|
||||
type=int,
|
||||
default=3,
|
||||
help='The number of huddles to create.'),
|
||||
make_option('--personals',
|
||||
help='The number of huddles to create.')
|
||||
|
||||
parser.add_argument('--personals',
|
||||
dest='num_personals',
|
||||
type='int',
|
||||
type=int,
|
||||
default=6,
|
||||
help='The number of personal pairs to create.'),
|
||||
make_option('--threads',
|
||||
help='The number of personal pairs to create.')
|
||||
|
||||
parser.add_argument('--threads',
|
||||
dest='threads',
|
||||
type='int',
|
||||
type=int,
|
||||
default=10,
|
||||
help='The number of threads to use.'),
|
||||
make_option('--percent-huddles',
|
||||
help='The number of threads to use.')
|
||||
|
||||
parser.add_argument('--percent-huddles',
|
||||
dest='percent_huddles',
|
||||
type='float',
|
||||
type=float,
|
||||
default=15,
|
||||
help='The percent of messages to be huddles.'),
|
||||
make_option('--percent-personals',
|
||||
help='The percent of messages to be huddles.')
|
||||
|
||||
parser.add_argument('--percent-personals',
|
||||
dest='percent_personals',
|
||||
type='float',
|
||||
type=float,
|
||||
default=15,
|
||||
help='The percent of messages to be personals.'),
|
||||
make_option('--stickyness',
|
||||
help='The percent of messages to be personals.')
|
||||
|
||||
parser.add_argument('--stickyness',
|
||||
dest='stickyness',
|
||||
type='float',
|
||||
type=float,
|
||||
default=20,
|
||||
help='The percent of messages to repeat recent folks.'),
|
||||
make_option('--nodelete',
|
||||
help='The percent of messages to repeat recent folks.')
|
||||
|
||||
parser.add_argument('--nodelete',
|
||||
action="store_false",
|
||||
default=True,
|
||||
dest='delete',
|
||||
help='Whether to delete all the existing messages.'),
|
||||
make_option('--test-suite',
|
||||
help='Whether to delete all the existing messages.')
|
||||
|
||||
parser.add_argument('--test-suite',
|
||||
default=False,
|
||||
action="store_true",
|
||||
help='Whether to delete all the existing messages.'),
|
||||
make_option('--replay-old-messages',
|
||||
help='Whether to delete all the existing messages.')
|
||||
|
||||
parser.add_argument('--replay-old-messages',
|
||||
action="store_true",
|
||||
default=False,
|
||||
dest='replay_old_messages',
|
||||
help='Whether to replace the log of old messages.'),
|
||||
)
|
||||
help='Whether to replace the log of old messages.')
|
||||
|
||||
def handle(self, **options):
|
||||
# type: (**Any) -> None
|
||||
|
||||
@@ -3,7 +3,7 @@ from typing import Any, Dict
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from optparse import make_option
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.core.management.base import BaseCommand, CommandParser
|
||||
from zerver.models import get_user_profile_by_email, UserMessage
|
||||
from zerver.views.messages import get_old_messages_backend
|
||||
import cProfile
|
||||
@@ -50,9 +50,9 @@ def profile_request(request):
|
||||
return ret
|
||||
|
||||
class Command(BaseCommand):
|
||||
option_list = BaseCommand.option_list + (
|
||||
make_option('--email', action='store'),
|
||||
)
|
||||
def add_arguments(self, parser):
|
||||
# type: (CommandParser) -> None
|
||||
parser.add_argument('--email', action='store')
|
||||
|
||||
def handle(self, *args, **options):
|
||||
# type: (*Any, **Any) -> None
|
||||
|
||||
Reference in New Issue
Block a user