Skip to content

Commit

Permalink
react(main) -> @react
Browse files Browse the repository at this point in the history
  • Loading branch information
meejah committed Mar 6, 2017
1 parent 0d65a79 commit d996f77
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 30 deletions.
4 changes: 1 addition & 3 deletions examples/connect.py
Expand Up @@ -7,6 +7,7 @@
import txtorcon


@react
@inlineCallbacks
def main(reactor):
ep = TCP4ClientEndpoint(reactor, "localhost", 9051)
Expand All @@ -21,6 +22,3 @@ def main(reactor):
print("Tor state created. Circuits:")
for circuit in state.circuits.values():
print(" {circuit.id}: {circuit.path}".format(circuit=circuit))


react(main)
4 changes: 1 addition & 3 deletions examples/disallow_streams_by_port.py
Expand Up @@ -53,6 +53,7 @@ def stream_closed(x):
return None


@react
@inlineCallbacks
def main(reactor):
control_ep = clientFromString(reactor, "tcp:localhost:9051")
Expand All @@ -67,6 +68,3 @@ def main(reactor):
for s in state.streams.values():
print(" ", s)
yield Deferred()


react(main)
5 changes: 1 addition & 4 deletions examples/dns_lookups.py
Expand Up @@ -6,6 +6,7 @@
import txtorcon


@react
@inlineCallbacks
def main(reactor):
control_ep = clientFromString(reactor, "tcp:localhost:9051")
Expand All @@ -17,7 +18,3 @@ def main(reactor):
print("Doing PTR on {}".format(ans))
ans = yield tor.dns_resolve_ptr(ans)
print("...got answer: {}".format(ans))


if __name__ == '__main__':
react(main)
5 changes: 1 addition & 4 deletions examples/launch_tor.py
Expand Up @@ -11,6 +11,7 @@
from twisted.internet.defer import inlineCallbacks


@react
@inlineCallbacks
def main(reactor):
# note that you can pass a few options as kwargs
Expand Down Expand Up @@ -55,7 +56,3 @@ def main(reactor):
print("Querying to see it changed:")
socksport = yield tor.protocol.get_conf("SOCKSPort")
print("SOCKSPort", socksport)


if __name__ == '__main__':
react(main)
4 changes: 1 addition & 3 deletions examples/launch_tor_endpoint.py
Expand Up @@ -23,6 +23,7 @@ def render_GET(self, request):
return "<html>Hello, world! I'm a hidden service!</html>"


@react
@inlineCallbacks
def main(reactor):
# several ways to proceed here and what they mean:
Expand Down Expand Up @@ -88,6 +89,3 @@ def sleep(s):
for i in range(10):
print("Stopping in {}...".format(10 - i))
yield sleep(1)


react(main)
5 changes: 1 addition & 4 deletions examples/launch_tor_unix_sockets.py
Expand Up @@ -17,6 +17,7 @@
from twisted.internet.defer import inlineCallbacks


@react
@inlineCallbacks
def main(reactor):
# we must have a directory owned by us with 0700 permissions to
Expand Down Expand Up @@ -57,7 +58,3 @@ def main(reactor):
body = yield readBody(resp)
print("received body ({} bytes)".format(len(body)))
print("{}\n[...]\n{}\n".format(body[:200], body[-200:]))


if __name__ == '__main__':
react(main)
5 changes: 1 addition & 4 deletions examples/web_client.py
Expand Up @@ -12,6 +12,7 @@
from txtorcon.util import default_control_port


@react
@inlineCallbacks
def main(reactor):
# use port 9051 for system tor instances, or:
Expand Down Expand Up @@ -39,7 +40,3 @@ def main(reactor):
body = yield readBody(resp)
print("received body ({} bytes)".format(len(body)))
print("{}\n[...]\n{}\n".format(body[:200], body[-200:]))


if __name__ == '__main__':
react(main)
3 changes: 1 addition & 2 deletions examples/web_client_custom_circuit.py
Expand Up @@ -17,6 +17,7 @@
from txtorcon.util import default_control_port


@react
@inlineCallbacks
def main(reactor):
# use port 9051 for system tor instances, or:
Expand Down Expand Up @@ -79,5 +80,3 @@ def connectionLost(self, reason):
yield d
print("All done, closing the circuit")
yield circ.close()

react(main)
4 changes: 1 addition & 3 deletions examples/web_client_treq.py
Expand Up @@ -18,6 +18,7 @@
raise SystemExit(1)


@react
@inlineCallbacks
def main(reactor):
ep = TCP4ClientEndpoint(reactor, '127.0.0.1', default_control_port())
Expand All @@ -37,6 +38,3 @@ def main(reactor):
data[:120],
data[-120:],
))


react(main)

0 comments on commit d996f77

Please sign in to comment.