Skip to content

Commit

Permalink
Merge PR267: improve sender-side instruction text
Browse files Browse the repository at this point in the history
  • Loading branch information
warner committed Dec 19, 2017
2 parents 1bbd756 + 67253bd commit 80852fb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 27 deletions.
17 changes: 9 additions & 8 deletions src/wormhole/cli/cmd_send.py
Expand Up @@ -92,16 +92,13 @@ def _go(self, w):
offer, self._fd_to_send = self._build_offer()
args = self._args

other_cmd = "wormhole receive"
other_cmd = u"wormhole receive"
if args.verify:
other_cmd = "wormhole receive --verify"
other_cmd = u"wormhole receive --verify"
if args.zeromode:
assert not args.code
args.code = u"0-"
other_cmd += " -0"

print(u"On the other computer, please run: %s" % other_cmd,
file=args.stderr)
other_cmd += u" -0"

if args.code:
w.set_code(args.code)
Expand All @@ -111,9 +108,13 @@ def _go(self, w):
code = yield w.get_code()
if not args.zeromode:
print(u"Wormhole code is: %s" % code, file=args.stderr)
# flush stderr so the code is displayed immediately
args.stderr.flush()
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
args.stderr.flush()

# 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
Expand Down
40 changes: 21 additions & 19 deletions src/wormhole/test/test_cli.py
Expand Up @@ -530,7 +530,7 @@ def message(i):
) as mrx_tm:
receive_d = cmd_receive.receive(recv_cfg)
else:
KEY_TIMER = 0 if mode == "slow-sender-text" else 1.0
KEY_TIMER = 0 if mode == "slow-sender-text" else 99999
rxw = []
with mock.patch.object(cmd_receive, "KEY_TIMER", KEY_TIMER):
send_d = cmd_send.send(send_cfg)
Expand All @@ -544,7 +544,7 @@ def message(i):

# The sender might fail, leaving the receiver hanging, or vice
# 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_send, "VERIFY_TIMER", VERIFY_TIMER):
if mock_accept:
Expand Down Expand Up @@ -589,9 +589,9 @@ def message(i):
# check sender
if mode == "text" or mode == "slow-text":
expected = ("Sending text message ({bytes:d} Bytes){NL}"
"On the other computer, please run: "
"wormhole receive{NL}"
"Wormhole code is: {code}{NL}{NL}"
"Wormhole code is: {code}{NL}"
"On the other computer, please run:{NL}{NL}"
"wormhole receive {code}{NL}{NL}"
"{KE}"
"text message sent{NL}").format(bytes=len(message),
code=send_cfg.code,
Expand All @@ -603,9 +603,9 @@ def message(i):
.format(size=naturalsize(len(message)),
name=send_filename,
NL=NL), send_stderr)
self.failUnlessIn(u"On the other computer, please run: "
"wormhole receive{NL}"
"Wormhole code is: {code}{NL}{NL}"
self.failUnlessIn(u"Wormhole code is: {code}{NL}"
"On the other computer, please run:{NL}{NL}"
"wormhole receive {code}{NL}{NL}"
.format(code=send_cfg.code, NL=NL),
send_stderr)
self.failUnlessIn(u"File sent.. waiting for confirmation{NL}"
Expand All @@ -614,9 +614,9 @@ def message(i):
elif mode == "directory":
self.failUnlessIn(u"Sending directory", send_stderr)
self.failUnlessIn(u"named 'testdir'", send_stderr)
self.failUnlessIn(u"On the other computer, please run: "
"wormhole receive{NL}"
"Wormhole code is: {code}{NL}{NL}"
self.failUnlessIn(u"Wormhole code is: {code}{NL}"
"On the other computer, please run:{NL}{NL}"
"wormhole receive {code}{NL}{NL}"
.format(code=send_cfg.code, NL=NL), send_stderr)
self.failUnlessIn(u"File sent.. waiting for confirmation{NL}"
"Confirmation received. Transfer complete.{NL}"
Expand Down Expand Up @@ -788,9 +788,9 @@ def _do_test_fail(self, mode, failmode):
.format(size=naturalsize(size),
name=send_filename,
NL=NL), send_stderr)
self.failUnlessIn("On the other computer, please run: "
"wormhole receive{NL}"
"Wormhole code is: {code}{NL}{NL}"
self.failUnlessIn("Wormhole code is: {code}{NL}"
"On the other computer, please run:{NL}{NL}"
"wormhole receive {code}{NL}"
.format(code=send_cfg.code, NL=NL),
send_stderr)
self.failIfIn("File sent.. waiting for confirmation{NL}"
Expand All @@ -799,9 +799,9 @@ def _do_test_fail(self, mode, failmode):
elif mode == "directory":
self.failUnlessIn("Sending directory", send_stderr)
self.failUnlessIn("named 'testdir'", send_stderr)
self.failUnlessIn("On the other computer, please run: "
"wormhole receive{NL}"
"Wormhole code is: {code}{NL}{NL}"
self.failUnlessIn("Wormhole code is: {code}{NL}"
"On the other computer, please run:{NL}{NL}"
"wormhole receive {code}{NL}"
.format(code=send_cfg.code, NL=NL), send_stderr)
self.failIfIn("File sent.. waiting for confirmation{NL}"
"Confirmation received. Transfer complete.{NL}"
Expand Down Expand Up @@ -893,8 +893,10 @@ def test_text(self):

# check sender
expected = ("Sending text message ({bytes:d} Bytes){NL}"
"On the other computer, please run: "
"wormhole receive -0{NL}{NL}"
"On the other computer, please run:{NL}"
"{NL}"
"wormhole receive -0{NL}"
"{NL}"
"text message sent{NL}").format(bytes=len(message),
code=send_cfg.code,
NL=NL)
Expand Down

0 comments on commit 80852fb

Please sign in to comment.