diff --git a/misc/dump-timing.py b/misc/dump-timing.py index 61e8fcb..a2c5544 100644 --- a/misc/dump-timing.py +++ b/misc/dump-timing.py @@ -43,9 +43,8 @@ def web(): root.putChild("lib", static.File(lib_root)) class Shutdown(resource.Resource): def render_GET(self, request): - if 0: - print("timeline ready, server shutting down") - reactor.stop() + #print("timeline ready, server shutting down") + #reactor.stop() return "shutting down" root.putChild("done", Shutdown()) site = server.Site(root) diff --git a/src/wormhole/_rlcompleter.py b/src/wormhole/_rlcompleter.py index c422435..95288dc 100644 --- a/src/wormhole/_rlcompleter.py +++ b/src/wormhole/_rlcompleter.py @@ -1,5 +1,5 @@ from __future__ import print_function, unicode_literals -import os, traceback +import traceback from sys import stderr try: import readline @@ -12,8 +12,8 @@ from twisted.internet.threads import deferToThread, blockingCallFromThread from .errors import KeyFormatError, AlreadyInputNameplateError errf = None -if 0: - errf = open("err", "w") if os.path.exists("err") else None +# uncomment this to enable tab-completion debugging +#import os ; errf = open("err", "w") if os.path.exists("err") else None def debug(*args, **kwargs): if errf: print(*args, file=errf, **kwargs) @@ -150,7 +150,6 @@ def _input_code_with_completion(prompt, input_helper, reactor): debug("==== readline-based completion is prepared") else: debug("==== unable to import readline, disabling completion") - pass code = input(prompt) # Code is str(bytes) on py2, and str(unicode) on py3. We want unicode. if isinstance(code, bytes): diff --git a/src/wormhole/server/cmd_usage.py b/src/wormhole/server/cmd_usage.py index 227a220..09aa494 100644 --- a/src/wormhole/server/cmd_usage.py +++ b/src/wormhole/server/cmd_usage.py @@ -1,6 +1,5 @@ from __future__ import print_function, unicode_literals import os, time, json -from collections import defaultdict import click from humanize import naturalsize from .database import get_db @@ -32,65 +31,6 @@ def print_event(event): def show_usage(args): print("closed for renovation") return 0 - if not os.path.exists("relay.sqlite"): - raise click.UsageError( - "cannot find relay.sqlite, please run from the server directory" - ) - oldest = None - newest = None - rendezvous_counters = defaultdict(int) - transit_counters = defaultdict(int) - total_transit_bytes = 0 - db = get_db("relay.sqlite") - c = db.execute("SELECT * FROM `usage`" - " ORDER BY `started` ASC LIMIT ?", - (args.n,)) - for row in c.fetchall(): - if row["type"] == "rendezvous": - counters = rendezvous_counters - elif row["type"] == "transit": - counters = transit_counters - total_transit_bytes += row["total_bytes"] - else: - continue - counters["total"] += 1 - counters[row["result"]] += 1 - if oldest is None or row["started"] < oldest: - oldest = row["started"] - if newest is None or row["started"] > newest: - newest = row["started"] - event = (row["type"], row["started"], row["result"], - row["total_bytes"], row["waiting_time"], row["total_time"]) - print_event(event) - if rendezvous_counters["total"] or transit_counters["total"]: - print("---") - print("(most recent started %s ago)" % abbrev(time.time() - newest)) - if rendezvous_counters["total"]: - print("rendezvous events:") - counters = rendezvous_counters - elapsed = time.time() - oldest - total = counters["total"] - print(" %d events in %s (%.2f per hour)" % (total, abbrev(elapsed), - (3600 * total / elapsed))) - print("", ", ".join(["%s=%d (%d%%)" % - (k, counters[k], (100.0 * counters[k] / total)) - for k in sorted(counters) - if k != "total"])) - if transit_counters["total"]: - print("transit events:") - counters = transit_counters - elapsed = time.time() - oldest - total = counters["total"] - print(" %d events in %s (%.2f per hour)" % (total, abbrev(elapsed), - (3600 * total / elapsed))) - rate = total_transit_bytes / elapsed - print(" %s total bytes, %sps" % (naturalsize(total_transit_bytes), - naturalsize(rate))) - print("", ", ".join(["%s=%d (%d%%)" % - (k, counters[k], (100.0 * counters[k] / total)) - for k in sorted(counters) - if k != "total"])) - return 0 def tail_usage(args): if not os.path.exists("relay.sqlite"): @@ -117,7 +57,6 @@ def tail_usage(args): time.sleep(2) except KeyboardInterrupt: return 0 - return 0 def count_channels(args): if not os.path.exists("relay.sqlite"): diff --git a/src/wormhole/transit.py b/src/wormhole/transit.py index e0a97dd..f8f824a 100644 --- a/src/wormhole/transit.py +++ b/src/wormhole/transit.py @@ -510,7 +510,6 @@ class InboundConnectionFactory(protocol.ClientFactory): def _proto_failed(self, f): # ignore these two, let Twisted log everything else f.trap(BadHandshake, defer.CancelledError) - pass def allocate_tcp_port(): """Return an (integer) available TCP port on localhost. This briefly