From 323175ddfe9e45664c40717d9de6a2459959f115 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Fri, 15 Apr 2016 17:00:11 -0700 Subject: [PATCH] split txwormhole step 1: move files --- setup.py | 3 +- .../twisted => txwormhole}/__init__.py | 0 .../eventsource.py} | 0 src/{wormhole/util => txwormhole}/eventual.py | 0 .../twisted => txwormhole}/ipaddrs.py | 0 .../twisted => txwormhole}/tor_manager.py | 0 .../twisted => txwormhole}/transcribe.py | 0 .../twisted => txwormhole}/transit.py | 0 src/wormhole/twisted/demo.py | 72 ------------------- 9 files changed, 2 insertions(+), 73 deletions(-) rename src/{wormhole/twisted => txwormhole}/__init__.py (100%) rename src/{wormhole/twisted/eventsource_twisted.py => txwormhole/eventsource.py} (100%) rename src/{wormhole/util => txwormhole}/eventual.py (100%) rename src/{wormhole/twisted => txwormhole}/ipaddrs.py (100%) rename src/{wormhole/twisted => txwormhole}/tor_manager.py (100%) rename src/{wormhole/twisted => txwormhole}/transcribe.py (100%) rename src/{wormhole/twisted => txwormhole}/transit.py (100%) delete mode 100644 src/wormhole/twisted/demo.py diff --git a/setup.py b/setup.py index eba24cd..286d283 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,8 @@ setup(name="magic-wormhole", url="https://github.com/warner/magic-wormhole", package_dir={"": "src"}, packages=["wormhole", - "wormhole.blocking", "wormhole.twisted", + "wormhole.blocking", + "txwormhole", "wormhole.scripts", "wormhole.test", "wormhole.util", "wormhole_server"], package_data={"wormhole_server": ["db-schemas/*.sql"]}, diff --git a/src/wormhole/twisted/__init__.py b/src/txwormhole/__init__.py similarity index 100% rename from src/wormhole/twisted/__init__.py rename to src/txwormhole/__init__.py diff --git a/src/wormhole/twisted/eventsource_twisted.py b/src/txwormhole/eventsource.py similarity index 100% rename from src/wormhole/twisted/eventsource_twisted.py rename to src/txwormhole/eventsource.py diff --git a/src/wormhole/util/eventual.py b/src/txwormhole/eventual.py similarity index 100% rename from src/wormhole/util/eventual.py rename to src/txwormhole/eventual.py diff --git a/src/wormhole/twisted/ipaddrs.py b/src/txwormhole/ipaddrs.py similarity index 100% rename from src/wormhole/twisted/ipaddrs.py rename to src/txwormhole/ipaddrs.py diff --git a/src/wormhole/twisted/tor_manager.py b/src/txwormhole/tor_manager.py similarity index 100% rename from src/wormhole/twisted/tor_manager.py rename to src/txwormhole/tor_manager.py diff --git a/src/wormhole/twisted/transcribe.py b/src/txwormhole/transcribe.py similarity index 100% rename from src/wormhole/twisted/transcribe.py rename to src/txwormhole/transcribe.py diff --git a/src/wormhole/twisted/transit.py b/src/txwormhole/transit.py similarity index 100% rename from src/wormhole/twisted/transit.py rename to src/txwormhole/transit.py diff --git a/src/wormhole/twisted/demo.py b/src/wormhole/twisted/demo.py deleted file mode 100644 index bc552e2..0000000 --- a/src/wormhole/twisted/demo.py +++ /dev/null @@ -1,72 +0,0 @@ -from __future__ import print_function -import sys, json -from twisted.python import log -from twisted.internet import reactor -from .transcribe import Wormhole -from .. import public_relay - -APPID = u"lothar.com/wormhole/text-or-file-xfer" -relay_url = public_relay.RENDEZVOUS_RELAY - -w = Wormhole(APPID, relay_url) - -if sys.argv[1] == "send": - message = sys.argv[2] - data = json.dumps({"message": message}).encode("utf-8") - d = w.get_code() - def _got_code(code): - print("code is:", code) - return w.send_data(data) - d.addCallback(_got_code) - def _sent(_): - return w.get_data() - d.addCallback(_sent) - def _got_data(them_bytes): - them_d = json.loads(them_bytes.decode("utf-8")) - if them_d["message_ack"] == "ok": - print("text sent") - else: - print("error sending text: %r" % (them_d,)) - d.addCallback(_got_data) -elif sys.argv[1] == "receive": - code = sys.argv[2].decode("utf-8") - w.set_code(code) - d = w.get_data() - def _got_data(them_bytes): - them_d = json.loads(them_bytes.decode("utf-8")) - if "error" in them_d: - print("ERROR: " + them_d["error"], file=sys.stderr) - raise RuntimeError - if "file" in them_d: - print("they're trying to send us a file, which I don't handle") - data = json.dumps({"error": "not capable of receiving files"}) - d1 = w.send_data(data.encode("utf-8")) - d1.addCallback(lambda _: RuntimeError()) - return d1 - if not "message" in them_d: - print("I don't know what they're offering\n") - print(them_d) - data = json.dumps({"error": "huh?"}) - d1 = w.send_data(data.encode("utf-8")) - d1.addCallback(lambda _: RuntimeError()) - return d1 - print(them_d["message"]) - data = json.dumps({"message_ack": "ok"}) - d1 = w.send_data(data.encode("utf-8")) - d1.addCallback(lambda _: 0) - return d1 - d.addCallback(_got_data) -else: - raise ValueError("bad command") - -d.addBoth(w.close) -rc = [] -def _success(res): - rc.append(res) -def _fail(f): - log.err(f) - rc.append(1) -d.addCallbacks(_success, _fail) -d.addCallback(lambda _: reactor.stop()) -reactor.run() -sys.exit(rc[0])