mirror of https://github.com/zulip/zulip.git
Replace optparse with argparse in the several management commands.
Specifically: * fill_memcached_caches.py * initialize_voyager_db.py * logout_all_users.py
This commit is contained in:
parent
7984c5af68
commit
fbdf539bf2
|
@ -2,14 +2,15 @@ from __future__ import absolute_import
|
|||
|
||||
from typing import Any
|
||||
|
||||
from optparse import make_option
|
||||
from argparse import ArgumentParser
|
||||
from django.core.management.base import BaseCommand
|
||||
from zerver.lib.cache_helpers import fill_remote_cache, cache_fillers
|
||||
|
||||
class Command(BaseCommand):
|
||||
option_list = BaseCommand.option_list + (
|
||||
make_option('--cache', dest="cache", default=None),)
|
||||
help = "Populate the memcached cache of messages."
|
||||
def parse_arguments(self, parser):
|
||||
# type: (ArgumentParser) -> None
|
||||
parser.add_argument('--cache', dest="cache", default=None,
|
||||
help="Populate the memcached cache of messages.")
|
||||
|
||||
def handle(self, *args, **options):
|
||||
# type: (*Any, **str) -> None
|
||||
|
|
|
@ -11,7 +11,7 @@ from django.conf import settings
|
|||
from zerver.lib.bulk_create import bulk_create_users
|
||||
from zerver.lib.actions import set_default_streams, do_create_realm
|
||||
|
||||
from optparse import make_option
|
||||
from argparse import ArgumentParser
|
||||
from six import text_type
|
||||
|
||||
settings.TORNADO_SERVER = None
|
||||
|
@ -31,13 +31,13 @@ def create_users(name_list, bot_type=None):
|
|||
class Command(BaseCommand):
|
||||
help = "Populate an initial database for Zulip Voyager"
|
||||
|
||||
option_list = BaseCommand.option_list + (
|
||||
make_option('--extra-users',
|
||||
dest='extra_users',
|
||||
type='int',
|
||||
default=0,
|
||||
help='The number of extra users to create'),
|
||||
)
|
||||
def parse_arguments(self, parser):
|
||||
# type: (ArgumentParser) -> None
|
||||
parser.add_argument('--extra-users',
|
||||
dest='extra_users',
|
||||
type=int,
|
||||
default=0,
|
||||
help='The number of extra users to create')
|
||||
|
||||
def handle(self, *args, **options):
|
||||
# type: (*Any, **Any) -> None
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from typing import Any
|
||||
from optparse import make_option
|
||||
from argparse import ArgumentParser
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
|
@ -12,17 +12,18 @@ from zerver.models import get_realm
|
|||
class Command(BaseCommand):
|
||||
help = "Log out all users."
|
||||
|
||||
option_list = BaseCommand.option_list + (
|
||||
make_option('--realm',
|
||||
dest='realm',
|
||||
action='store',
|
||||
default=None,
|
||||
help="Only logout all users in a particular realm"),
|
||||
make_option('--deactivated-only',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help="Only logout all users who are deactivated"),
|
||||
)
|
||||
def parse_arguments(self, parser):
|
||||
# type: (ArgumentParser) -> None
|
||||
parser.add_argument('--realm',
|
||||
dest='realm',
|
||||
action='store',
|
||||
default=None,
|
||||
help="Only logout all users in a particular realm")
|
||||
parser.add_argument('--deactivated-only',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help="Only logout all users who are deactivated")
|
||||
|
||||
|
||||
def handle(self, *args, **options):
|
||||
# type: (*Any, **Any) -> None
|
||||
|
|
Loading…
Reference in New Issue