From b0da2a9ac723a2ef54f4c514faeec95f65b92cac Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Sun, 24 Apr 2016 22:46:21 -0700 Subject: [PATCH] cmd_send: fold helper routines back into main function These were split out to make the blocking- and twisted- based implementations share some code, but now that we're down to just Twisted, it's clearer to merge them back in. --- src/wormhole/cli/cmd_send.py | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/wormhole/cli/cmd_send.py b/src/wormhole/cli/cmd_send.py index 4d5d67d..ced71f6 100644 --- a/src/wormhole/cli/cmd_send.py +++ b/src/wormhole/cli/cmd_send.py @@ -13,11 +13,20 @@ APPID = u"lothar.com/wormhole/text-or-file-xfer" @inlineCallbacks def send_twisted(args, reactor=reactor): assert isinstance(args.relay_url, type(u"")) - handle_zero(args) + if args.zeromode: + assert not args.code + args.code = u"0-" + # TODO: parallelize the roundtrip that allocates the channel with the # (blocking) local IO (file os.stat, zipfile generation) phase1, fd_to_send = build_phase1_data(args) - other_cmd = build_other_command(args) + + other_cmd = "wormhole receive" + if args.verify: + other_cmd = "wormhole --verify receive" + if args.zeromode: + other_cmd += " -0" + print(u"On the other computer, please run: %s" % other_cmd, file=args.stdout) @@ -104,11 +113,6 @@ def send_twisted(args, reactor=reactor): args.stdout, args.hide_progress, args.timing) returnValue(0) -def handle_zero(args): - if args.zeromode: - assert not args.code - args.code = u"0-" - def build_phase1_data(args): phase1 = {} @@ -181,14 +185,6 @@ def build_phase1_data(args): raise TypeError("'%s' is neither file nor directory" % args.what) -def build_other_command(args): - other_cmd = "wormhole receive" - if args.verify: - other_cmd = "wormhole --verify receive" - if args.zeromode: - other_cmd += " -0" - return other_cmd - @inlineCallbacks def _send_file_twisted(tdata, transit_sender, fd_to_send, stdout, hide_progress, timing):