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:
Laura Hampton 2016-10-15 18:29:57 -04:00 committed by Tim Abbott
parent 7984c5af68
commit fbdf539bf2
3 changed files with 26 additions and 24 deletions

View File

@ -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

View File

@ -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

View File

@ -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