From cf592d0766223e496a84152a9bcd4db4fc1a564d Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Wed, 1 Apr 2015 16:01:32 -0700 Subject: [PATCH] CLI: avoid importing anything until command is actually run In prep for moving the server launch command into the main CLI path, without imposing dependency on pynacl/etc. --- src/wormhole/scripts/cmd_receive_file.py | 9 +++++---- src/wormhole/scripts/cmd_receive_text.py | 5 +++-- src/wormhole/scripts/cmd_send_file.py | 9 +++++---- src/wormhole/scripts/cmd_send_text.py | 5 +++-- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/wormhole/scripts/cmd_receive_file.py b/src/wormhole/scripts/cmd_receive_file.py index 68a485d..c072558 100644 --- a/src/wormhole/scripts/cmd_receive_file.py +++ b/src/wormhole/scripts/cmd_receive_file.py @@ -1,13 +1,14 @@ from __future__ import print_function -import sys, os, json, binascii -from wormhole.blocking.transcribe import Receiver, WrongPasswordError -from wormhole.blocking.transit import TransitReceiver, TransitError -from .progress import start_progress, update_progress, finish_progress APPID = "lothar.com/wormhole/file-xfer" def receive_file(args): # we're receiving + import sys, os, json, binascii + from wormhole.blocking.transcribe import Receiver, WrongPasswordError + from wormhole.blocking.transit import TransitReceiver, TransitError + from .progress import start_progress, update_progress, finish_progress + transit_receiver = TransitReceiver(args.transit_helper) r = Receiver(APPID, args.relay_url) diff --git a/src/wormhole/scripts/cmd_receive_text.py b/src/wormhole/scripts/cmd_receive_text.py index 7d3b566..13c0a84 100644 --- a/src/wormhole/scripts/cmd_receive_text.py +++ b/src/wormhole/scripts/cmd_receive_text.py @@ -1,11 +1,12 @@ from __future__ import print_function -import sys, json, binascii -from wormhole.blocking.transcribe import Receiver, WrongPasswordError APPID = "lothar.com/wormhole/text-xfer" def receive_text(args): # we're receiving + import sys, json, binascii + from wormhole.blocking.transcribe import Receiver, WrongPasswordError + r = Receiver(APPID, args.relay_url) code = args.code if not code: diff --git a/src/wormhole/scripts/cmd_send_file.py b/src/wormhole/scripts/cmd_send_file.py index 23fe34d..a74cbf6 100644 --- a/src/wormhole/scripts/cmd_send_file.py +++ b/src/wormhole/scripts/cmd_send_file.py @@ -1,13 +1,14 @@ from __future__ import print_function -import os, sys, json, binascii -from wormhole.blocking.transcribe import Initiator, WrongPasswordError -from wormhole.blocking.transit import TransitSender -from .progress import start_progress, update_progress, finish_progress APPID = "lothar.com/wormhole/file-xfer" def send_file(args): # we're sending + import os, sys, json, binascii + from wormhole.blocking.transcribe import Initiator, WrongPasswordError + from wormhole.blocking.transit import TransitSender + from .progress import start_progress, update_progress, finish_progress + filename = args.filename assert os.path.isfile(filename) transit_sender = TransitSender(args.transit_helper) diff --git a/src/wormhole/scripts/cmd_send_text.py b/src/wormhole/scripts/cmd_send_text.py index 4f865ad..881faef 100644 --- a/src/wormhole/scripts/cmd_send_text.py +++ b/src/wormhole/scripts/cmd_send_text.py @@ -1,11 +1,12 @@ from __future__ import print_function -import sys, json, binascii -from wormhole.blocking.transcribe import Initiator, WrongPasswordError APPID = "lothar.com/wormhole/text-xfer" def send_text(args): # we're sending + import sys, json, binascii + from wormhole.blocking.transcribe import Initiator, WrongPasswordError + i = Initiator(APPID, args.relay_url) code = i.get_code(args.code_length) print("On the other computer, please run: wormhole receive-text")