2013-10-19 15:28:59 +02:00
|
|
|
from __future__ import absolute_import
|
2015-11-01 17:11:06 +01:00
|
|
|
from __future__ import print_function
|
2013-10-19 15:28:59 +02:00
|
|
|
|
2016-06-04 16:52:18 +02:00
|
|
|
from typing import Any
|
|
|
|
|
2017-01-30 06:28:33 +01:00
|
|
|
from zerver.lib.actions import create_stream_if_needed
|
2016-07-05 03:39:01 +02:00
|
|
|
from zerver.lib.str_utils import force_text
|
2017-08-08 15:07:03 +02:00
|
|
|
from zerver.lib.management import ZulipBaseCommand
|
2013-10-19 15:28:59 +02:00
|
|
|
|
2016-06-04 16:52:18 +02:00
|
|
|
from argparse import ArgumentParser
|
2013-10-19 15:28:59 +02:00
|
|
|
import sys
|
|
|
|
|
2017-08-08 15:07:03 +02:00
|
|
|
class Command(ZulipBaseCommand):
|
2013-10-19 15:28:59 +02:00
|
|
|
help = """Create a stream, and subscribe all active users (excluding bots).
|
|
|
|
|
|
|
|
This should be used for TESTING only, unless you understand the limitations of
|
2015-08-21 02:10:41 +02:00
|
|
|
the command."""
|
2013-10-19 15:28:59 +02:00
|
|
|
|
2015-08-21 02:10:41 +02:00
|
|
|
def add_arguments(self, parser):
|
2016-06-04 16:52:18 +02:00
|
|
|
# type: (ArgumentParser) -> None
|
2017-08-08 15:07:03 +02:00
|
|
|
self.add_realm_args(parser, True, "realm in which to create the stream")
|
2015-08-21 02:10:41 +02:00
|
|
|
parser.add_argument('stream_name', metavar='<stream name>', type=str,
|
|
|
|
help='name of stream to create')
|
2013-10-19 15:28:59 +02:00
|
|
|
|
|
|
|
def handle(self, *args, **options):
|
2016-06-04 16:52:18 +02:00
|
|
|
# type: (*Any, **str) -> None
|
2017-08-08 15:07:03 +02:00
|
|
|
realm = self.get_realm(options)
|
2013-10-19 15:28:59 +02:00
|
|
|
encoding = sys.getfilesystemencoding()
|
2016-07-05 03:39:01 +02:00
|
|
|
stream_name = options['stream_name']
|
2017-01-30 06:28:33 +01:00
|
|
|
create_stream_if_needed(realm, force_text(stream_name, encoding))
|