mirror of https://github.com/zulip/zulip.git
tools/zulip-export/zulip-export: Fix how files are opened.
Instead of using codecs.open, use the builtin open in binary mode and write data after encoding it in utf-8.
This commit is contained in:
parent
df7dcdda5f
commit
b08d6769c1
|
@ -62,7 +62,6 @@ bots/githook-post-receive
|
|||
tools/deprecated/inject-messages/inject-messages
|
||||
tools/deprecated/review
|
||||
tools/update-deployment
|
||||
tools/zulip-export/zulip-export
|
||||
""".split()
|
||||
|
||||
exclude_scripts_py2 = [] # type: List[str]
|
||||
|
|
|
@ -25,7 +25,6 @@ from __future__ import print_function
|
|||
import sys
|
||||
import os.path
|
||||
import optparse
|
||||
import codecs
|
||||
import time
|
||||
import json
|
||||
usage = """Export all messages on a given stream to a JSON dump.
|
||||
|
@ -79,8 +78,8 @@ for msg in result['messages']:
|
|||
messages.append(msg)
|
||||
|
||||
filename = "zulip-%s.json" % (options.stream,)
|
||||
f = codecs.open(filename, encoding='utf-8', mode="wb")
|
||||
f.write(json.dumps(messages, indent=0, sort_keys=False))
|
||||
f = open(filename, mode="wb")
|
||||
f.write(json.dumps(messages, indent=0, sort_keys=False).encode('utf-8'))
|
||||
f.close()
|
||||
print("%d messages exported to %s" % (len(messages), filename,))
|
||||
sys.exit(0)
|
||||
|
|
Loading…
Reference in New Issue