From 6abecebb648d098343d0305103bfc5f50237c5c9 Mon Sep 17 00:00:00 2001 From: ng0 Date: Sun, 3 Dec 2017 11:26:17 +0000 Subject: rename examples. --- examples/dht.py | 25 +++++++++++++++++++++++++ examples/example-dht.py | 25 ------------------------- examples/example-gns.py | 15 --------------- examples/gns.py | 15 +++++++++++++++ 4 files changed, 40 insertions(+), 40 deletions(-) create mode 100755 examples/dht.py delete mode 100755 examples/example-dht.py delete mode 100755 examples/example-gns.py create mode 100755 examples/gns.py diff --git a/examples/dht.py b/examples/dht.py new file mode 100755 index 0000000..76f345b --- /dev/null +++ b/examples/dht.py @@ -0,0 +1,25 @@ +#!/usr/bin/python3 + +import gnunet.dht +import time + +key = gnunet.HashCode("RMKN0U1JNA3PVCL148D6JI0STVG94A8A65INOK849CF1RT6BGF26AMMT14GMDMNRDFSJRJME6IKJ3LDFBUL2R1TPQJE64I55I32QN5G") + +gnunet.dht.put(key, 1, "test", b"hello") + + +def result_callback(block_type, key, data, expiry, get_path, put_path): + print("Got result from DHT") + print(" block_type == %s" % repr(block_type)) + print(" key == %s" % repr(key)) + print(" expiry == %s" % repr(expiry)) + print(" get_path == %s" % repr(get_path)) + print(" put_path == %s" % repr(put_path)) + print(" data == %s" % repr(data)) + + +req = gnunet.dht.get_start(result_callback, "test", key, 1, record_route=True) +req.filter_known_results([]) +req.stop() + +time.sleep(1) diff --git a/examples/example-dht.py b/examples/example-dht.py deleted file mode 100755 index 76f345b..0000000 --- a/examples/example-dht.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/python3 - -import gnunet.dht -import time - -key = gnunet.HashCode("RMKN0U1JNA3PVCL148D6JI0STVG94A8A65INOK849CF1RT6BGF26AMMT14GMDMNRDFSJRJME6IKJ3LDFBUL2R1TPQJE64I55I32QN5G") - -gnunet.dht.put(key, 1, "test", b"hello") - - -def result_callback(block_type, key, data, expiry, get_path, put_path): - print("Got result from DHT") - print(" block_type == %s" % repr(block_type)) - print(" key == %s" % repr(key)) - print(" expiry == %s" % repr(expiry)) - print(" get_path == %s" % repr(get_path)) - print(" put_path == %s" % repr(put_path)) - print(" data == %s" % repr(data)) - - -req = gnunet.dht.get_start(result_callback, "test", key, 1, record_route=True) -req.filter_known_results([]) -req.stop() - -time.sleep(1) diff --git a/examples/example-gns.py b/examples/example-gns.py deleted file mode 100755 index efbea27..0000000 --- a/examples/example-gns.py +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/python3 - -import gnunet.gns - - -results = gnunet.gns.lookup("www.gnu", "JK55QA8JLAL64MBO8UM209KE93M9JBBO7M2UB8M3M03FKRFSUOMG", "A", True) - -for r in results: - print("Got result from gns") - print(" record_type == %s" % repr(r.record_type)) - print(" data == %s" % repr(r.data)) - print(" expiration_time == %s" % repr(r.expiration_time)) - print(" private == %s" % repr(r.private)) - print(" pending == %s" % repr(r.pending)) - print(" shadow == %s" % repr(r.shadow)) diff --git a/examples/gns.py b/examples/gns.py new file mode 100755 index 0000000..efbea27 --- /dev/null +++ b/examples/gns.py @@ -0,0 +1,15 @@ +#!/usr/bin/python3 + +import gnunet.gns + + +results = gnunet.gns.lookup("www.gnu", "JK55QA8JLAL64MBO8UM209KE93M9JBBO7M2UB8M3M03FKRFSUOMG", "A", True) + +for r in results: + print("Got result from gns") + print(" record_type == %s" % repr(r.record_type)) + print(" data == %s" % repr(r.data)) + print(" expiration_time == %s" % repr(r.expiration_time)) + print(" private == %s" % repr(r.private)) + print(" pending == %s" % repr(r.pending)) + print(" shadow == %s" % repr(r.shadow)) -- cgit v1.2.3