Tests pass on Python 3.
This commit is contained in:
parent
d182ba8283
commit
e140dc06ea
|
@ -5,13 +5,12 @@ from __future__ import absolute_import
|
||||||
from __future__ import division
|
from __future__ import division
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from future.utils import PY2
|
from future.utils import PY2, PY3
|
||||||
if PY2:
|
if PY2:
|
||||||
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
|
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
|
||||||
|
|
||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
import json
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from allmydata.scripts.types_ import SubCommands
|
from allmydata.scripts.types_ import SubCommands
|
||||||
|
@ -32,7 +31,7 @@ from allmydata.scripts.common import (
|
||||||
from allmydata.scripts.default_nodedir import _default_nodedir
|
from allmydata.scripts.default_nodedir import _default_nodedir
|
||||||
from allmydata.util.assertutil import precondition
|
from allmydata.util.assertutil import precondition
|
||||||
from allmydata.util.encodingutil import listdir_unicode, argv_to_unicode, quote_local_unicode_path, get_io_encoding
|
from allmydata.util.encodingutil import listdir_unicode, argv_to_unicode, quote_local_unicode_path, get_io_encoding
|
||||||
from allmydata.util import fileutil, i2p_provider, iputil, tor_provider
|
from allmydata.util import fileutil, i2p_provider, iputil, tor_provider, jsonbytes as json
|
||||||
|
|
||||||
from wormhole import wormhole
|
from wormhole import wormhole
|
||||||
|
|
||||||
|
@ -389,7 +388,7 @@ def _get_config_via_wormhole(config):
|
||||||
"client-v1": {},
|
"client-v1": {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wh.send_message(json.dumps(intro))
|
wh.send_message(json.dumps_bytes(intro))
|
||||||
|
|
||||||
server_intro = yield wh.get_message()
|
server_intro = yield wh.get_message()
|
||||||
server_intro = json.loads(server_intro)
|
server_intro = json.loads(server_intro)
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import json
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from allmydata.scripts.types_ import SubCommands
|
from allmydata.scripts.types_ import SubCommands
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -13,6 +11,7 @@ from twisted.internet import defer, reactor
|
||||||
from wormhole import wormhole
|
from wormhole import wormhole
|
||||||
|
|
||||||
from allmydata.util.encodingutil import argv_to_abspath
|
from allmydata.util.encodingutil import argv_to_abspath
|
||||||
|
from allmydata.util import jsonbytes as json
|
||||||
from allmydata.scripts.common import get_default_nodedir, get_introducer_furl
|
from allmydata.scripts.common import get_default_nodedir, get_introducer_furl
|
||||||
from allmydata.node import read_config
|
from allmydata.node import read_config
|
||||||
|
|
||||||
|
@ -54,7 +53,7 @@ def _send_config_via_wormhole(options, config):
|
||||||
code = yield wh.get_code()
|
code = yield wh.get_code()
|
||||||
print("Invite Code for client: {}".format(code), file=out)
|
print("Invite Code for client: {}".format(code), file=out)
|
||||||
|
|
||||||
wh.send_message(json.dumps({
|
wh.send_message(json.dumps_bytes({
|
||||||
u"abilities": {
|
u"abilities": {
|
||||||
u"server-v1": {},
|
u"server-v1": {},
|
||||||
}
|
}
|
||||||
|
@ -71,7 +70,7 @@ def _send_config_via_wormhole(options, config):
|
||||||
defer.returnValue(1)
|
defer.returnValue(1)
|
||||||
|
|
||||||
print(" transmitting configuration", file=out)
|
print(" transmitting configuration", file=out)
|
||||||
wh.send_message(json.dumps(config))
|
wh.send_message(json.dumps_bytes(config))
|
||||||
yield wh.close()
|
yield wh.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
from past.builtins import unicode
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import mock
|
import mock
|
||||||
import json
|
import json
|
||||||
|
@ -48,6 +50,10 @@ class _FakeWormhole(object):
|
||||||
|
|
||||||
|
|
||||||
def _create_fake_wormhole(outgoing_messages):
|
def _create_fake_wormhole(outgoing_messages):
|
||||||
|
outgoing_messages = [
|
||||||
|
m.encode("utf-8") if isinstance(m, unicode) else m
|
||||||
|
for m in outgoing_messages
|
||||||
|
]
|
||||||
return _FakeWormhole(outgoing_messages)
|
return _FakeWormhole(outgoing_messages)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue