Merge PR267: improve sender-side instruction text

This commit is contained in:
Brian Warner 2017-12-19 15:07:33 -08:00
commit 80852fb2de
2 changed files with 30 additions and 27 deletions

View File

@ -92,16 +92,13 @@ class Sender:
offer, self._fd_to_send = self._build_offer() offer, self._fd_to_send = self._build_offer()
args = self._args args = self._args
other_cmd = "wormhole receive" other_cmd = u"wormhole receive"
if args.verify: if args.verify:
other_cmd = "wormhole receive --verify" other_cmd = u"wormhole receive --verify"
if args.zeromode: if args.zeromode:
assert not args.code assert not args.code
args.code = u"0-" args.code = u"0-"
other_cmd += " -0" other_cmd += u" -0"
print(u"On the other computer, please run: %s" % other_cmd,
file=args.stderr)
if args.code: if args.code:
w.set_code(args.code) w.set_code(args.code)
@ -111,9 +108,13 @@ class Sender:
code = yield w.get_code() code = yield w.get_code()
if not args.zeromode: if not args.zeromode:
print(u"Wormhole code is: %s" % code, file=args.stderr) print(u"Wormhole code is: %s" % code, file=args.stderr)
other_cmd += u" " + code
print(u"On the other computer, please run:", file=args.stderr)
print(u"", file=args.stderr)
print(other_cmd, file=args.stderr)
print(u"", file=args.stderr)
# flush stderr so the code is displayed immediately # flush stderr so the code is displayed immediately
args.stderr.flush() args.stderr.flush()
print(u"", file=args.stderr)
# We don't print a "waiting" message for get_unverified_key() here, # We don't print a "waiting" message for get_unverified_key() here,
# even though we do that in cmd_receive.py, because it's not at all # even though we do that in cmd_receive.py, because it's not at all

View File

@ -530,7 +530,7 @@ class PregeneratedCode(ServerBase, ScriptsBase, unittest.TestCase):
) as mrx_tm: ) as mrx_tm:
receive_d = cmd_receive.receive(recv_cfg) receive_d = cmd_receive.receive(recv_cfg)
else: else:
KEY_TIMER = 0 if mode == "slow-sender-text" else 1.0 KEY_TIMER = 0 if mode == "slow-sender-text" else 99999
rxw = [] rxw = []
with mock.patch.object(cmd_receive, "KEY_TIMER", KEY_TIMER): with mock.patch.object(cmd_receive, "KEY_TIMER", KEY_TIMER):
send_d = cmd_send.send(send_cfg) send_d = cmd_send.send(send_cfg)
@ -544,7 +544,7 @@ class PregeneratedCode(ServerBase, ScriptsBase, unittest.TestCase):
# The sender might fail, leaving the receiver hanging, or vice # The sender might fail, leaving the receiver hanging, or vice
# versa. Make sure we don't wait on one side exclusively # versa. Make sure we don't wait on one side exclusively
VERIFY_TIMER = 0 if mode == "slow-text" else 1.0 VERIFY_TIMER = 0 if mode == "slow-text" else 99999
with mock.patch.object(cmd_receive, "VERIFY_TIMER", VERIFY_TIMER): with mock.patch.object(cmd_receive, "VERIFY_TIMER", VERIFY_TIMER):
with mock.patch.object(cmd_send, "VERIFY_TIMER", VERIFY_TIMER): with mock.patch.object(cmd_send, "VERIFY_TIMER", VERIFY_TIMER):
if mock_accept: if mock_accept:
@ -589,9 +589,9 @@ class PregeneratedCode(ServerBase, ScriptsBase, unittest.TestCase):
# check sender # check sender
if mode == "text" or mode == "slow-text": if mode == "text" or mode == "slow-text":
expected = ("Sending text message ({bytes:d} Bytes){NL}" expected = ("Sending text message ({bytes:d} Bytes){NL}"
"On the other computer, please run: " "Wormhole code is: {code}{NL}"
"wormhole receive{NL}" "On the other computer, please run:{NL}{NL}"
"Wormhole code is: {code}{NL}{NL}" "wormhole receive {code}{NL}{NL}"
"{KE}" "{KE}"
"text message sent{NL}").format(bytes=len(message), "text message sent{NL}").format(bytes=len(message),
code=send_cfg.code, code=send_cfg.code,
@ -603,9 +603,9 @@ class PregeneratedCode(ServerBase, ScriptsBase, unittest.TestCase):
.format(size=naturalsize(len(message)), .format(size=naturalsize(len(message)),
name=send_filename, name=send_filename,
NL=NL), send_stderr) NL=NL), send_stderr)
self.failUnlessIn(u"On the other computer, please run: " self.failUnlessIn(u"Wormhole code is: {code}{NL}"
"wormhole receive{NL}" "On the other computer, please run:{NL}{NL}"
"Wormhole code is: {code}{NL}{NL}" "wormhole receive {code}{NL}{NL}"
.format(code=send_cfg.code, NL=NL), .format(code=send_cfg.code, NL=NL),
send_stderr) send_stderr)
self.failUnlessIn(u"File sent.. waiting for confirmation{NL}" self.failUnlessIn(u"File sent.. waiting for confirmation{NL}"
@ -614,9 +614,9 @@ class PregeneratedCode(ServerBase, ScriptsBase, unittest.TestCase):
elif mode == "directory": elif mode == "directory":
self.failUnlessIn(u"Sending directory", send_stderr) self.failUnlessIn(u"Sending directory", send_stderr)
self.failUnlessIn(u"named 'testdir'", send_stderr) self.failUnlessIn(u"named 'testdir'", send_stderr)
self.failUnlessIn(u"On the other computer, please run: " self.failUnlessIn(u"Wormhole code is: {code}{NL}"
"wormhole receive{NL}" "On the other computer, please run:{NL}{NL}"
"Wormhole code is: {code}{NL}{NL}" "wormhole receive {code}{NL}{NL}"
.format(code=send_cfg.code, NL=NL), send_stderr) .format(code=send_cfg.code, NL=NL), send_stderr)
self.failUnlessIn(u"File sent.. waiting for confirmation{NL}" self.failUnlessIn(u"File sent.. waiting for confirmation{NL}"
"Confirmation received. Transfer complete.{NL}" "Confirmation received. Transfer complete.{NL}"
@ -788,9 +788,9 @@ class PregeneratedCode(ServerBase, ScriptsBase, unittest.TestCase):
.format(size=naturalsize(size), .format(size=naturalsize(size),
name=send_filename, name=send_filename,
NL=NL), send_stderr) NL=NL), send_stderr)
self.failUnlessIn("On the other computer, please run: " self.failUnlessIn("Wormhole code is: {code}{NL}"
"wormhole receive{NL}" "On the other computer, please run:{NL}{NL}"
"Wormhole code is: {code}{NL}{NL}" "wormhole receive {code}{NL}"
.format(code=send_cfg.code, NL=NL), .format(code=send_cfg.code, NL=NL),
send_stderr) send_stderr)
self.failIfIn("File sent.. waiting for confirmation{NL}" self.failIfIn("File sent.. waiting for confirmation{NL}"
@ -799,9 +799,9 @@ class PregeneratedCode(ServerBase, ScriptsBase, unittest.TestCase):
elif mode == "directory": elif mode == "directory":
self.failUnlessIn("Sending directory", send_stderr) self.failUnlessIn("Sending directory", send_stderr)
self.failUnlessIn("named 'testdir'", send_stderr) self.failUnlessIn("named 'testdir'", send_stderr)
self.failUnlessIn("On the other computer, please run: " self.failUnlessIn("Wormhole code is: {code}{NL}"
"wormhole receive{NL}" "On the other computer, please run:{NL}{NL}"
"Wormhole code is: {code}{NL}{NL}" "wormhole receive {code}{NL}"
.format(code=send_cfg.code, NL=NL), send_stderr) .format(code=send_cfg.code, NL=NL), send_stderr)
self.failIfIn("File sent.. waiting for confirmation{NL}" self.failIfIn("File sent.. waiting for confirmation{NL}"
"Confirmation received. Transfer complete.{NL}" "Confirmation received. Transfer complete.{NL}"
@ -893,8 +893,10 @@ class ZeroMode(ServerBase, unittest.TestCase):
# check sender # check sender
expected = ("Sending text message ({bytes:d} Bytes){NL}" expected = ("Sending text message ({bytes:d} Bytes){NL}"
"On the other computer, please run: " "On the other computer, please run:{NL}"
"wormhole receive -0{NL}{NL}" "{NL}"
"wormhole receive -0{NL}"
"{NL}"
"text message sent{NL}").format(bytes=len(message), "text message sent{NL}").format(bytes=len(message),
code=send_cfg.code, code=send_cfg.code,
NL=NL) NL=NL)