From f3641864d0b43d97d30aed48e874ddfb33813f3d Mon Sep 17 00:00:00 2001 From: Brian Muller Date: Tue, 2 Jan 2018 14:17:36 -0500 Subject: [PATCH] fixed examples --- docs/index.rst | 6 +++--- docs/intro.rst | 18 +++++++----------- docs/querying.rst | 4 ++-- examples/get.py | 9 +++++---- examples/set.py | 9 +++++---- 5 files changed, 22 insertions(+), 24 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index 6148bba..f8f4758 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -7,13 +7,13 @@ Kademlia Documentation ====================== .. note :: - This library assumes you have a working familiarity with Twisted_. + This library assumes you have a working familiarity with asyncio_. -This library is an asynchronous Python implementation of the `Kademlia distributed hash table `_. It uses Twisted_ to provide asynchronous communication. The nodes communicate using `RPC over UDP `_ to communiate, meaning that it is capable of working behind a `NAT `_. +This library is an asynchronous Python implementation of the `Kademlia distributed hash table `_. It uses asyncio_ to provide asynchronous communication. The nodes communicate using `RPC over UDP `_ to communiate, meaning that it is capable of working behind a `NAT `_. This library aims to be as close to a reference implementation of the `Kademlia paper `_ as possible. -.. _Twisted: https://twistedmatrix.com +.. _asyncio: https://docs.python.org/3/library/asyncio.html .. toctree:: :maxdepth: 3 diff --git a/docs/intro.rst b/docs/intro.rst index 9929d37..07110a4 100644 --- a/docs/intro.rst +++ b/docs/intro.rst @@ -8,29 +8,25 @@ The easiest (and best) way to install kademlia is through `pip ") +if len(sys.argv) != 4: + print("Usage: python get.py ") sys.exit(1) handler = logging.StreamHandler() @@ -20,8 +20,9 @@ loop.set_debug(True) server = Server() server.listen(8469) -loop.run_until_complete(server.bootstrap([("127.0.0.1", 8468)])) -result = loop.run_until_complete(server.get(sys.argv[1])) +bootstrap_node = (sys.argv[1], int(sys.argv[2])) +loop.run_until_complete(server.bootstrap([bootstrap_node])) +result = loop.run_until_complete(server.get(sys.argv[3])) server.stop() loop.close() diff --git a/examples/set.py b/examples/set.py index cf274cf..1b2aae2 100644 --- a/examples/set.py +++ b/examples/set.py @@ -4,8 +4,8 @@ import sys from kademlia.network import Server -if len(sys.argv) != 3: - print("Usage: python set.py ") +if len(sys.argv) != 5: + print("Usage: python set.py ") sys.exit(1) handler = logging.StreamHandler() @@ -20,7 +20,8 @@ loop.set_debug(True) server = Server() server.listen(8469) -loop.run_until_complete(server.bootstrap([("127.0.0.1", 8468)])) -loop.run_until_complete(server.set(sys.argv[1], sys.argv[2])) +bootstrap_node = (sys.argv[1], int(sys.argv[2])) +loop.run_until_complete(server.bootstrap([bootstrap_node])) +loop.run_until_complete(server.set(sys.argv[3], sys.argv[4])) server.stop() loop.close()