Home | Trees | Indices | Help |
|
---|
|
An implementation of a freenet client library for FCP v2, offering considerable flexibility.
Clients should instantiate FCPNode, then execute its methods to perform tasks with FCP.
This module was written by aum, May 2006, released under the GNU Lesser General Public License.
No warranty, yada yada
For FCP documentation, see http://wiki.freenetproject.org/FCPv2
|
|||
ConnectionRefused cannot connect to given host/port |
|||
PrivacyRisk The following code would pose a privacy risk |
|||
FCPException | |||
FCPGetFailed | |||
FCPPutFailed | |||
FCPProtocolError | |||
FCPNodeFailure node seems to have died |
|||
FCPSendTimeout timed out waiting for command to be sent to node |
|||
FCPNodeTimeout timed out waiting for node to respond |
|||
FCPNameLookupFailure name services name lookup failed |
|||
FCPNode Represents an interface to a freenet node via its FCP port, and exposes primitives for the basic genkey, get, put and putdir operations as well as peer management primitives. |
|||
JobTicket A JobTicket is an object returned to clients making asynchronous requests. |
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|
Reads a directory, returning a sequence of file dicts. TODO: Currently this uses sha1 as hash. Freenet uses 256. But the hashes are not used. Arguments: - dirpath - relative or absolute pathname of directory to scan - gethashes - also include a 'hash' key in each file dict, being the SHA1 hash of the file's name and contents Each returned dict in the sequence has the keys: - fullpath - usable for opening/reading file - relpath - relative path of file (the part after 'dirpath'), for the 'SSK@blahblah//relpath' URI - mimetype - guestimated mimetype for file >>> tempdir = tempfile.mkdtemp() >>> filename = "test.txt" >>> testfile = os.path.join(tempdir, filename) >>> with open(testfile, "w") as f: ... f.write("test") >>> correct = [{'mimetype': 'text/plain', 'fullpath': testfile, 'relpath': filename}] >>> correct == readdir(tempdir) True >>> tempdir = tempfile.mkdtemp() >>> filename = "test" >>> testfile = os.path.join(tempdir, filename) >>> with open(testfile, "w") as f: ... f.write("test") >>> correct = [{'mimetype': 'application/octet-stream', 'fullpath': testfile, 'relpath': filename}] >>> correct == readdir(tempdir) True >>> res = readdir(tempdir, gethashes=True) >>> res[0]["hash"] == hashFile(testfile) True |
returns an SHA(1) hash of a file's contents >>> oslevelid, filepath = tempfile.mkstemp(text=True) >>> with open(filepath, "w") as f: ... f.write("test") >>> hashFile(filepath) == hashlib.sha1("test").hexdigest() True |
returns a sha256 hash of a file's contents for bypassing TestDDA >>> oslevelid, filepath = tempfile.mkstemp(text=True) >>> with open(filepath, "wb") as f: ... f.write("test") >>> print sha256dda("1","2",filepath) == hashlib.sha256("1-2-" + "test").digest() True |
Make a filename url-safe, keeping only the basename and killing all potentially unfitting characters. :returns: urlsafe basename of the file as string. |
analyses an SSK URI, and determines if it is an SSK or USK private key for details see https://wiki.freenetproject.org/Signed_Subspace_Key >>> uriIsPrivate("SSK@~Udj39wzRUN4J-Kqn1aWN8kJyHL6d44VSyWoqSjL60A,iAtIH8348UGKfs8lW3mw0lm0D9WLwtsIzZhvMWelpK0,AQACAAE/") False >>> uriIsPrivate("SSK@R-skbNbiXqWkqj8FPDTusWyk7u8HLvbdysyRY3eY9A0,iAtIH8348UGKfs8lW3mw0lm0D9WLwtsIzZhvMWelpK0,AQECAAE/") True >>> uriIsPrivate("USK@AIcCHvrGspY-7J73J3VR-Td3DuPvw3IqCyjjRK6EvJol,hEvqa41cm72Wc9O1AjZ0OoDU9JVGAvHDDswIE68pT7M,AQECAAE/test.R1/0") True >>> uriIsPrivate("KSK@AIcCHvrGspY-7J73J3VR-Td3DuPvw3IqCyjjRK6EvJol,hEvqa41cm72Wc9O1AjZ0OoDU9JVGAvHDDswIE68pT7M,AQECAAE/test.R1/0") False >>> uriIsPrivate("SSK@JhtPxdPLx30sRN0c5S2Hhcsif~Yqy1lsGiAx5Wkq7Lo,-e0kLAjmmclSR7uL0TN901tS3iSx2-21Id8tUp4tyzg,AQECAAE/") True |
Parses a time value, recognising suffices like 'm' for minutes, 's' for seconds, 'h' for hours, 'd' for days, 'w' for weeks, 'M' for months. >>> endings = {'s':1, 'm':60, 'h':60*60, 'd':60*60*24, 'w':60*60*24*7, 'M':60*60*24*30} >>> not False in [endings[i]*3 == parseTime("3"+i) for i in endings] True Returns time value in seconds |
Decodes a freenet-encoded base64 string back to a binary string Arguments:
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Wed May 27 18:05:39 2015 | http://epydoc.sourceforge.net |