magic-wormhole/bin/send_text.py

19 lines
509 B
Python
Raw Normal View History

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-11 09:18:31 +00:00
from wormhole.transcribe import Initiator
2015-02-11 00:50:32 +00:00
APPID = "lothar.com/wormhole/text-xfer"
# we're sending
message = sys.argv[1]
data = json.dumps({"message": message,
2015-02-11 00:50:32 +00:00
}).encode("utf-8")
i = Initiator(APPID, data)
code = i.get_code()
print("On the other computer, please run: receive_text")
print("Wormhole code is: %s" % code)
2015-02-11 09:18:31 +00:00
print("")
them_bytes = i.get_data()
2015-02-11 00:50:32 +00:00
them_d = json.loads(them_bytes.decode("utf-8"))
print("them: %r" % (them_d,))