fcp2: high level wrapper for the freenet client protocol written in python. Automatic
conversions from Fcp to python types, access to node and peer configurations and much more.
The package is designed as drop anywhere package so you can include it into any project as
library. No need to install it to the sites directory.
Sample code:
Connect to the freenet node
import fcp2
client = fcp2.Client()
nodeHello = client.connect()
if nodeHello is None:
pass
else:
pass
Request data associated to a freenet key
myKey = fcp2.Key('CHK@ABCDE.......')
myRequestIdentifier = client.getData(key)
myRequest = client.getRequest(myIdentifier)
client.run()
print myRequest.data
Usually you would connect handlers to client events to do processing or handle errors
def handleSuccess(event, request):
print 'Here is the data:', request.data
def handleFailure(event, request):
print 'Too bad, something went wrong'
client.events.RequestCompleted += handleSuccess
client.events.RequestFailed += handleFailure
myKey = fcp2.Key('CHK@ABCDE.......')
client.getData(myKey)
client.run()
Instead of calling run() you may run the client step by step
myKey = fcp2.Key('CHK@ABCDE.......')
client.getData('CHK@ABCDE.......')
for i in xrange(50):
client.next()
You may disconnect event handlers as well
client.events.RequestCompleted -= handleSuccess
client.events.RequestFailed -= handleFailure
Multiple event handlers may be connected / disconnected at once
client.events += (
(client.events.RequestCompleted, handleSuccess),
(client.events.RequestFailed, handleFailure)
)
To generate extensive documentation run the package through [epydoc].
To make things a bit simpler script gen_docs.py located in the
scripts subdirectory of the package wich will dump docs automatically to the
packages doc folder.