[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [GNUnet-developers] gnunet-python library
From: |
Christian Grothoff |
Subject: |
Re: [GNUnet-developers] gnunet-python library |
Date: |
Sat, 19 Apr 2014 21:27:49 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131103 Icedove/17.0.10 |
Dear Andrew,
First of all, great progress, this looks like the DBus stuff is
starting to be really useful!
As with DBus, I'd be happy to setup a directory svn/gnunet-python/ on
gnunet.org for you, so that the code is also available from the
'central' code repository.
Also, it would probably be helpful to extend the developer handbook
with a chapter on the Python binding (and DBus...). At the least, we
clearly should mention in the handbook that the binding(s) exist(s).
I don't recall if you have the permissions set up for that; if you don't
let me know and I'll be happy to fix them.
Happy hacking!
Christian
On 04/18/14 16:08, Andrew Cann wrote:
> I've started writing a gnunet library for python. It uses thet gnunet-dbus
> bindings available on subversion. You can clone it from:
>
> git clone git://canndrew.org/gnunet-python.git
>
> Currently it can do everything that the dbus wrapper can do, which is putting
> and getting from the dht and doing gns lookups.
>
> Here's some example code (available in the repo):
>
> ## example-dht.py
> #!/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))
>
> gnunet.dht.get_start(result_callback, "test", key, 1, record_route=True)
>
> time.sleep(1)
>
> ## example output
> Got result from DHT
> block_type == 'test'
> key ==
> gnunet.HashCode('RMKN0U1JNA3PVCL148D6JI0STVG94A8A65INOK849CF1RT6BGF26AMMT14GMDMNRDFSJRJME6IKJ3LDFBUL2R1TPQJE64I55I32QN5G')
> expiry == None
> get_path == []
> put_path == []
> data == bytearray(b'hello')
> Got result from DHT
> block_type == 'test'
> key ==
> gnunet.HashCode('RMKN0U1JNA3PVCL148D6JI0STVG94A8A65INOK849CF1RT6BGF26AMMT14GMDMNRDFSJRJME6IKJ3LDFBUL2R1TPQJE64I55I32QN5G')
> expiry == None
> get_path == []
> put_path == []
> data == bytearray(b'')
>
> ## example-gns.py
> #!/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))
>
> ## example output
> Got result from gns
> record_type == 'A'
> data == '1.2.3.4'
> expiration_time == None
> private == True
> pending == False
> shadow == False
>
>
>
> _______________________________________________
> GNUnet-developers mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/gnunet-developers
>
signature.asc
Description: OpenPGP digital signature