zulip: Move from simplejson to json.
This removes the simplejson dependency.
This commit is contained in:
parent
18157095c4
commit
631c64ca6c
|
@ -4,7 +4,6 @@ The [Zulip API](https://zulipchat.com/api) Python bindings require the
|
||||||
following Python libraries:
|
following Python libraries:
|
||||||
|
|
||||||
* requests (version >= 0.12.1)
|
* requests (version >= 0.12.1)
|
||||||
* simplejson
|
|
||||||
* six
|
* six
|
||||||
* typing (version >= 3.5.2.2)
|
* typing (version >= 3.5.2.2)
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import os
|
||||||
import logging
|
import logging
|
||||||
import optparse
|
import optparse
|
||||||
import time
|
import time
|
||||||
import simplejson
|
import json
|
||||||
import subprocess
|
import subprocess
|
||||||
import unicodedata
|
import unicodedata
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ if __name__ == "__main__":
|
||||||
continue
|
continue
|
||||||
|
|
||||||
f = open("/home/zulip/public_streams.tmp", "w")
|
f = open("/home/zulip/public_streams.tmp", "w")
|
||||||
f.write(simplejson.dumps(list(public_streams)) + "\n")
|
f.write(json.dumps(list(public_streams)) + "\n")
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
subprocess.call(["mv", "/home/zulip/public_streams.tmp", "/home/zulip/public_streams"])
|
subprocess.call(["mv", "/home/zulip/public_streams.tmp", "/home/zulip/public_streams"])
|
||||||
|
|
|
@ -27,10 +27,7 @@ from types import FrameType
|
||||||
import sys
|
import sys
|
||||||
from six.moves import map
|
from six.moves import map
|
||||||
from six.moves import range
|
from six.moves import range
|
||||||
try:
|
import json
|
||||||
import simplejson
|
|
||||||
except ImportError:
|
|
||||||
import json as simplejson # type: ignore
|
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -205,7 +202,7 @@ def update_subscriptions():
|
||||||
# type: () -> None
|
# type: () -> None
|
||||||
try:
|
try:
|
||||||
f = open(options.stream_file_path, "r")
|
f = open(options.stream_file_path, "r")
|
||||||
public_streams = simplejson.loads(f.read())
|
public_streams = json.loads(f.read())
|
||||||
f.close()
|
f.close()
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception("Error reading public streams:")
|
logger.exception("Error reading public streams:")
|
||||||
|
@ -447,7 +444,7 @@ def process_notice(notice, log):
|
||||||
logger.info("Received a message on %s/%s from %s..." %
|
logger.info("Received a message on %s/%s from %s..." %
|
||||||
(zephyr_class, notice.instance, notice.sender))
|
(zephyr_class, notice.instance, notice.sender))
|
||||||
if log is not None:
|
if log is not None:
|
||||||
log.write(simplejson.dumps(zeph) + '\n')
|
log.write(json.dumps(zeph) + '\n')
|
||||||
log.flush()
|
log.flush()
|
||||||
|
|
||||||
if os.fork() == 0:
|
if os.fork() == 0:
|
||||||
|
@ -552,7 +549,7 @@ def zephyr_to_zulip(options):
|
||||||
with open(options.logs_to_resend, 'r') as log:
|
with open(options.logs_to_resend, 'r') as log:
|
||||||
for ln in log:
|
for ln in log:
|
||||||
try:
|
try:
|
||||||
zeph = simplejson.loads(ln)
|
zeph = json.loads(ln)
|
||||||
# New messages added to the log shouldn't have any
|
# New messages added to the log shouldn't have any
|
||||||
# elements of type str (they should already all be
|
# elements of type str (they should already all be
|
||||||
# unicode), but older messages in the log are
|
# unicode), but older messages in the log are
|
||||||
|
|
|
@ -65,7 +65,6 @@ package_info = dict(
|
||||||
|
|
||||||
setuptools_info = dict(
|
setuptools_info = dict(
|
||||||
install_requires=['requests>=0.12.1',
|
install_requires=['requests>=0.12.1',
|
||||||
'simplejson',
|
|
||||||
'six',
|
'six',
|
||||||
'typing>=3.5.2.2',
|
'typing>=3.5.2.2',
|
||||||
],
|
],
|
||||||
|
@ -80,11 +79,6 @@ except ImportError:
|
||||||
from distutils.core import setup
|
from distutils.core import setup
|
||||||
from distutils.version import LooseVersion
|
from distutils.version import LooseVersion
|
||||||
# Manual dependency check
|
# Manual dependency check
|
||||||
try:
|
|
||||||
import simplejson
|
|
||||||
except ImportError:
|
|
||||||
print("simplejson is not installed", file=sys.stderr)
|
|
||||||
sys.exit(1)
|
|
||||||
try:
|
try:
|
||||||
import requests
|
import requests
|
||||||
assert(LooseVersion(requests.__version__) >= LooseVersion('0.12.1'))
|
assert(LooseVersion(requests.__version__) >= LooseVersion('0.12.1'))
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
from __future__ import division
|
from __future__ import division
|
||||||
import simplejson
|
import json
|
||||||
import requests
|
import requests
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
|
@ -434,7 +434,7 @@ class Client(object):
|
||||||
if isinstance(val, str) or isinstance(val, Text):
|
if isinstance(val, str) or isinstance(val, Text):
|
||||||
request[key] = val
|
request[key] = val
|
||||||
else:
|
else:
|
||||||
request[key] = simplejson.dumps(val)
|
request[key] = json.dumps(val)
|
||||||
|
|
||||||
for f in files:
|
for f in files:
|
||||||
req_files.append((f.name, f))
|
req_files.append((f.name, f))
|
||||||
|
@ -459,7 +459,7 @@ class Client(object):
|
||||||
else:
|
else:
|
||||||
sys.stdout.write(".")
|
sys.stdout.write(".")
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
query_state["request"]["dont_block"] = simplejson.dumps(True)
|
query_state["request"]["dont_block"] = json.dumps(True)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
query_state["failures"] += 1
|
query_state["failures"] += 1
|
||||||
return True
|
return True
|
||||||
|
|
Loading…
Reference in a new issue