2015-02-11 09:18:31 +00:00
|
|
|
from __future__ import print_function
|
2015-02-11 00:50:32 +00:00
|
|
|
import sys, json
|
2015-02-20 08:32:48 +00:00
|
|
|
from wormhole.blocking.transcribe import Initiator, WrongPasswordError
|
2015-02-11 00:50:32 +00:00
|
|
|
|
|
|
|
APPID = "lothar.com/wormhole/text-xfer"
|
|
|
|
|
|
|
|
# we're sending
|
|
|
|
message = sys.argv[1]
|
2015-02-11 10:09:26 +00:00
|
|
|
data = json.dumps({"message": message,
|
2015-02-11 00:50:32 +00:00
|
|
|
}).encode("utf-8")
|
2015-02-11 10:09:26 +00:00
|
|
|
i = Initiator(APPID, data)
|
2015-02-11 02:34:13 +00:00
|
|
|
code = i.get_code()
|
2015-02-15 01:48:38 +00:00
|
|
|
print("On the other computer, please run: receive_text")
|
|
|
|
print("Wormhole code is: %s" % code)
|
2015-02-11 09:18:31 +00:00
|
|
|
print("")
|
2015-02-20 08:32:48 +00:00
|
|
|
try:
|
|
|
|
them_bytes = i.get_data()
|
|
|
|
except WrongPasswordError as e:
|
|
|
|
print("ERROR: " + e.explain(), file=sys.stderr)
|
|
|
|
sys.exit(1)
|
2015-02-11 00:50:32 +00:00
|
|
|
them_d = json.loads(them_bytes.decode("utf-8"))
|
|
|
|
print("them: %r" % (them_d,))
|