magic-wormhole/bin/receive_text.py

17 lines
533 B
Python
Raw Normal View History

2015-02-11 09:18:31 +00:00
from __future__ import print_function
import time, json
from wormhole.blocking.transcribe import Receiver
from wormhole.codes import input_code_with_completion
2015-02-11 00:50:32 +00:00
APPID = "lothar.com/wormhole/text-xfer"
# we're receiving
data = json.dumps({"message": "ok"}).encode("utf-8")
r = Receiver(APPID, data)
r.set_code(r.input_code("Enter receive-text wormhole code: "))
start = time.time()
them_bytes = r.get_data()
2015-02-11 00:50:32 +00:00
them_d = json.loads(them_bytes.decode("utf-8"))
print(them_d["message"])
2015-02-11 09:45:54 +00:00
print("elapsed time: %.2f" % (time.time() - start))