mirror of https://github.com/zulip/zulip.git
create_stream.py: Fix broken code.
* get_realm returns None if no matching realm is present, but create_stream.py assumed it raises Realm.DoesNotExist. * encoded/decode strings properly.
This commit is contained in:
parent
7956fcbf0d
commit
17cb6e00bd
|
@ -41,7 +41,6 @@ exclude_py2 = []
|
|||
|
||||
exclude_py3 = """
|
||||
zerver/lib/ccache.py
|
||||
zerver/management/commands/create_stream.py
|
||||
zerver/management/commands/email-mirror.py
|
||||
zerver/management/commands/enqueue_file.py
|
||||
zerver/management/commands/rename_stream.py
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
from __future__ import absolute_import
|
||||
from __future__ import print_function
|
||||
|
||||
from six import text_type
|
||||
from typing import Any
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
from zerver.lib.actions import do_create_stream
|
||||
from zerver.lib.str_utils import force_text
|
||||
from zerver.models import Realm, get_realm
|
||||
|
||||
from argparse import ArgumentParser
|
||||
|
@ -27,13 +29,12 @@ the command."""
|
|||
def handle(self, *args, **options):
|
||||
# type: (*Any, **str) -> None
|
||||
domain = options['domain']
|
||||
stream_name = options['stream_name']
|
||||
encoding = sys.getfilesystemencoding()
|
||||
stream_name = options['stream_name']
|
||||
|
||||
try:
|
||||
realm = get_realm(domain)
|
||||
except Realm.DoesNotExist:
|
||||
realm = get_realm(force_text(domain, encoding))
|
||||
if realm is None:
|
||||
print("Unknown domain %s" % (domain,))
|
||||
exit(1)
|
||||
|
||||
do_create_stream(realm, stream_name.decode(encoding))
|
||||
else:
|
||||
do_create_stream(realm, force_text(stream_name, encoding))
|
||||
|
|
Loading…
Reference in New Issue