Thread: SF.net SVN: fclient: [403] trunk/sandbox/fcp2/client.py (Page 2)
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <jU...@us...> - 2008-05-05 11:18:25
|
Revision: 403
http://fclient.svn.sourceforge.net/fclient/?rev=403&view=rev
Author: jUrner
Date: 2008-05-05 04:18:18 -0700 (Mon, 05 May 2008)
Log Message:
-----------
got two close events (atexit triggered the sdecond). fixed
Modified Paths:
--------------
trunk/sandbox/fcp2/client.py
Modified: trunk/sandbox/fcp2/client.py
===================================================================
--- trunk/sandbox/fcp2/client.py 2008-05-05 08:00:40 UTC (rev 402)
+++ trunk/sandbox/fcp2/client.py 2008-05-05 11:18:18 UTC (rev 403)
@@ -308,10 +308,11 @@
self._ddaTests = []
self._requests = {}
+ #TODO: complain if we are already closed?
if self.ioHandler.isOpen():
self.ioHandler.close()
- if msg is not None:
- self.events.ClientDisconnected(msg)
+ if msg is not None:
+ self.events.ClientDisconnected(msg)
#TODO: check if this method is still needed
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-05-05 11:18:49
|
Revision: 404
http://fclient.svn.sourceforge.net/fclient/?rev=404&view=rev
Author: jUrner
Date: 2008-05-05 04:18:52 -0700 (Mon, 05 May 2008)
Log Message:
-----------
typos
Modified Paths:
--------------
trunk/sandbox/fcp2/client.py
Modified: trunk/sandbox/fcp2/client.py
===================================================================
--- trunk/sandbox/fcp2/client.py 2008-05-05 11:18:18 UTC (rev 403)
+++ trunk/sandbox/fcp2/client.py 2008-05-05 11:18:52 UTC (rev 404)
@@ -853,7 +853,7 @@
code = msg['Code']
if code == consts.FetchError.Canceled:
- initialRequest['RequestStatus'] |= onsts.RequestStatus.Removed | consts.RequestStatus.Completed | consts.RequestStatus.RemovedFromQueue
+ initialRequest['RequestStatus'] |= consts.RequestStatus.Removed | consts.RequestStatus.Completed | consts.RequestStatus.RemovedFromQueue
del self._requests[requestIdentifier]
self.events.RequestRemoved(initialRequest)
return True
@@ -984,7 +984,7 @@
code = msg['Code']
if code == consts.InsertError.Canceled:
- initialRequest['RequestStatus'] |= onsts.RequestStatus.Removed | consts.RequestStatus.Completed | consts.RequestStatus.RemovedFromQueue
+ initialRequest['RequestStatus'] |= consts.RequestStatus.Removed | consts.RequestStatus.Completed | consts.RequestStatus.RemovedFromQueue
del self._requests[requestIdentifier]
self.events.RequestRemoved(initialRequest)
return True
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-05-05 11:29:09
|
Revision: 405
http://fclient.svn.sourceforge.net/fclient/?rev=405&view=rev
Author: jUrner
Date: 2008-05-05 04:29:14 -0700 (Mon, 05 May 2008)
Log Message:
-----------
a few more notes
Modified Paths:
--------------
trunk/sandbox/fcp2/client.py
Modified: trunk/sandbox/fcp2/client.py
===================================================================
--- trunk/sandbox/fcp2/client.py 2008-05-05 11:18:52 UTC (rev 404)
+++ trunk/sandbox/fcp2/client.py 2008-05-05 11:29:14 UTC (rev 405)
@@ -143,10 +143,15 @@
# removbe request is now handled uniformly in Fcp. modify request not yet.
#
#-------------------------------------------------------------------------------------------------------------------------------------------------
+# [0002202: drop global persistents ]
+#
+# suggested dropping of global persistents. pretty dangerous and unhandy imo.
+#
+#
+#--------------------------------------------------------------------------------------------------------------------------------------------------
-
# Todos
#------------------------------------------------------------------------------------------------------------------------------------------------
# clean up
@@ -2127,7 +2132,8 @@
raise ValueError('Can not modify request: %s' % initialRequest.name)
#FIX: [0002083]
- # no way to change priority here ..this is simply not implemented in the protocol
+ # no way to change priority for non-persistent requests..this is simply not implemented in the protocol
+ # persistentUserData is ok, priority can not be changed. no idea how to handle this.
if initialRequest['Persistence'] == consts.Persistence.Connection:
modified = {}
#if priorityClass is not None:
@@ -2141,6 +2147,7 @@
initialRequest['Modified'] = modified
self.events.RequestModified(initialRequest)
return
+ #/FIX: [0002083]
msg = message.ModifyPersistentRequest(
Identifier=initialRequest['Identifier'],
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-06-28 07:57:56
|
Revision: 406
http://fclient.svn.sourceforge.net/fclient/?rev=406&view=rev
Author: jUrner
Date: 2008-06-28 00:58:02 -0700 (Sat, 28 Jun 2008)
Log Message:
-----------
bug #0001965 got fixed. remove fix from client
Modified Paths:
--------------
trunk/sandbox/fcp2/client.py
Modified: trunk/sandbox/fcp2/client.py
===================================================================
--- trunk/sandbox/fcp2/client.py 2008-05-05 11:29:14 UTC (rev 405)
+++ trunk/sandbox/fcp2/client.py 2008-06-28 07:58:02 UTC (rev 406)
@@ -103,13 +103,6 @@
# minor one
#
#FIX: None
-#------------------------------------------------------------------------------------------------------------------------------------------------
-# [0001965: Persistence vs PersistenceType]
-#
-# PersistentGet passes persistence field as "PersistenceType", PersistentPut as "Persistence"
-# already fixed this here in the client
-#
-# FIX: implemented in client
#-------------------------------------------------------------------------------------------------------------------------------------------------
# [0002015: Drop the global queue]
#
@@ -913,9 +906,6 @@
#FIX: remove Started param from PersistentGet / Put
if 'Started' in initialRequest.params:
del initialRequest.params['Started']
- #FIX: [0001965: Persistence vs PersistenceType]
- if 'PersistenceType' in initialRequest.params:
- initialRequest['Persistence'] = initialRequest.params.pop('PersistenceType')
initialRequest['RequestStatus'] |= consts.RequestStatus.Restored
self.events.RequestRestored(initialRequest)
return True
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-06-28 08:13:29
|
Revision: 407
http://fclient.svn.sourceforge.net/fclient/?rev=407&view=rev
Author: jUrner
Date: 2008-06-28 01:13:38 -0700 (Sat, 28 Jun 2008)
Log Message:
-----------
ClientDisconnected() was not triggered when the client was already closed. fixed
Modified Paths:
--------------
trunk/sandbox/fcp2/client.py
Modified: trunk/sandbox/fcp2/client.py
===================================================================
--- trunk/sandbox/fcp2/client.py 2008-06-28 07:58:02 UTC (rev 406)
+++ trunk/sandbox/fcp2/client.py 2008-06-28 08:13:38 UTC (rev 407)
@@ -295,6 +295,8 @@
@param msg: message to pass to the ClientDisconnected event or None to not inform listeners
@todo: complain if the client is already closed?
+ @todo: trigger ClientDisconnected() if the client is already closed? should be yes. otherwise
+ we'd have to distinguish between intentional and unintentional closing like on a broken io
"""
consts.Logger.Client.info(consts.LogMessages.Closing)
@@ -306,12 +308,11 @@
self._ddaTests = []
self._requests = {}
- #TODO: complain if we are already closed?
+ if msg is not None:
+ self.events.ClientDisconnected(msg)
if self.ioHandler.isOpen():
self.ioHandler.close()
- if msg is not None:
- self.events.ClientDisconnected(msg)
-
+
#TODO: check if this method is still needed
def _finalizeRequest(self, msg, request, event):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-06-28 08:38:40
|
Revision: 412
http://fclient.svn.sourceforge.net/fclient/?rev=412&view=rev
Author: jUrner
Date: 2008-06-28 01:38:50 -0700 (Sat, 28 Jun 2008)
Log Message:
-----------
some notes on PutComplexDir vs PutDiskDir
Modified Paths:
--------------
trunk/sandbox/fcp2/client.py
Modified: trunk/sandbox/fcp2/client.py
===================================================================
--- trunk/sandbox/fcp2/client.py 2008-06-28 08:37:59 UTC (rev 411)
+++ trunk/sandbox/fcp2/client.py 2008-06-28 08:38:50 UTC (rev 412)
@@ -182,10 +182,10 @@
# TODO: check if this is a bug in Fcp
# NOTE: seems to be fixed in [build 1112], fixes removed
#-------------------------------------------------------------------------------------------------------------------------------------------------
-# PutComplexDir
+# PersistentPutDiskDir vs PutComplexDir
#
-# x. currently not handled on PersistentPut. have to test this
-#
+# x. currently not handled on PersistentPutDir. have to test this
+# Fcp provides a new field "PutDirType": "complex" or "disk" to distinguish PutComplexDir and PutDiskDir
#
#------------------------------------------------------------------------------------------------------------------------------------------------
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-06-29 10:59:05
|
Revision: 417
http://fclient.svn.sourceforge.net/fclient/?rev=417&view=rev
Author: jUrner
Date: 2008-06-29 03:59:13 -0700 (Sun, 29 Jun 2008)
Log Message:
-----------
get / put methods expect a key object now
Modified Paths:
--------------
trunk/sandbox/fcp2/client.py
Modified: trunk/sandbox/fcp2/client.py
===================================================================
--- trunk/sandbox/fcp2/client.py 2008-06-29 10:58:33 UTC (rev 416)
+++ trunk/sandbox/fcp2/client.py 2008-06-29 10:59:13 UTC (rev 417)
@@ -968,7 +968,7 @@
initialRequest['ProgressRequired'] = msg['Required']
initialRequest['ProgressFailed'] = msg['Failed']
initialRequest['ProgressFatalyFailed'] = msg['FatallyFailed']
- initialRequest['ProgressSucceeeded'] = msg['Succeeded']
+ initialRequest['ProgressSucceeded'] = msg['Succeeded']
self.events.RequestProgress(initialRequest)
return True
@@ -1271,7 +1271,7 @@
**messageParams
):
"""Requests a key from the node
- @param key: (str) key or Uri of the file to request (may contain prefixes like 'freenet:' or 'http://')
+ @param key: (L{key.KeyBase}) key to request
@param requestType: (L{consts.RequestType}) sub type of the message
@param userData: any non persistent data to associate to the request or None
@param persistentUserData: any string to associate to the request as persistent data or None
@@ -1279,11 +1279,8 @@
@param messageParams: keyword arguments to pass along with the ClientGet message (uppercase first letter!!).
If the value of a keyword is None, it is ignored.
- @return: (str) identifier of the request
+ @return: (str) request identifier
"""
- if hasattr(key, 'toString'):
- key = key.toString()
-
msg = message.ClientGet(URI=key)
for paramName, value in messageParams.items():
if value is not None:
@@ -1318,7 +1315,7 @@
):
"""Requests datae from the node
- @param key: (str) key or Uri of the data to request (may contain prefixes like 'freenet:' or 'http://')
+ @param key: (L{key.KeyBase}) key to request
@param allowedMimeTypes: (str) list of allowed mime types
@param binaryBlob: (bool) if True, the file is retrieved as binary blob file
@@ -1386,7 +1383,7 @@
):
"""Requests a file from the node
- @param key: (str) key or Uri of the file to request (may contain prefixes like 'freenet:' or 'http://')
+ @param key: (L{key.KeyBase}) key to request
@param filename: (full path) filename to store the file to
@param allowedMimeTypes: (str) list of allowed mime types
@@ -1451,7 +1448,7 @@
):
"""Requests info about a key
- @param key: (str) key or Uri of the file to request (may contain prefixes like 'freenet:' or 'http://')
+ @param key: (L{key.KeyBase}) key to request
@param dsOnly: if True, retrieves the file from the local data store only
@param ignoreDS: If True, ignores the local data store
@@ -1497,17 +1494,15 @@
#TESTED
def subscribeUSK(self, key, dontPoll=True):
"""Asks the node to notify the client when an USK is updated
- @param key: (str) key or Uri of the USK to subscribe to
+ @param key: (L{key.USK}) key to subscribe to
@param dontPoll: if True, does whatever ???
@return: (str) identifer of the request
- @note: this request can not be removed or modified and the {consts.RequestStatus.Completed}
+ @note: this request can not be removed or modified so the L{consts.RequestStatus.Completed}
flag is always set
@todo: looks like USK subscribes will persist untill connection is closed. Can they be removed somehow?
"""
- if hasattr(key, 'toString'):
- key = key.toString()
msg = message.SubscribeUSK(
URI=key,
DontPoll=dontPoll,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-06-29 12:37:35
|
Revision: 421
http://fclient.svn.sourceforge.net/fclient/?rev=421&view=rev
Author: jUrner
Date: 2008-06-29 05:37:43 -0700 (Sun, 29 Jun 2008)
Log Message:
-----------
SSKKeypair was broken. fixed
++ some other changes
Modified Paths:
--------------
trunk/sandbox/fcp2/client.py
Modified: trunk/sandbox/fcp2/client.py
===================================================================
--- trunk/sandbox/fcp2/client.py 2008-06-29 12:36:50 UTC (rev 420)
+++ trunk/sandbox/fcp2/client.py 2008-06-29 12:37:43 UTC (rev 421)
@@ -22,10 +22,11 @@
# everything went well ..we are connected now
Request data associated to a freenet key::
- myRequestIdentifier = client.getData('CHK@ABCDE.......')
- myRequest = c.getRequest(myIdentifier)
- client.run()
- print myRequest.data
+ myKey = client.key.key('CHK@ABCDE.......')
+ myRequestIdentifier = client.getData(myKey)
+ myRequest = c.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):
@@ -34,17 +35,18 @@
def handleFailure(event, request):
print 'Too bad, something went wrong'
- client.events.RequestCompleted += handleSuccess
- client.events.RequestFailed += handleFailure
+ client.events.RequestCompleted += handleSuccess
+ client.events.RequestFailed += handleFailure
+ myKey = client.key.key('CHK@ABCDE.......')
+ client.getData(myKey)
+ c.run()
- client.getData('CHK@ABCDE.......')
- c.run()
-
Instead of calling run() you may run the client step by step::
- client.getData('CHK@ABCDE.......')
- for i in xrange(50):
- client.next()
+ myKey = client.key.key('CHK@ABCDE.......')
+ client.getData(myKey)
+ for i in xrange(50):
+ client.next()
You may disconnect event handlers aswell::
@@ -936,7 +938,7 @@
# So no way.
#TODO: ??? try ...except
- initialRequest.restorePersistentParams()
+ initialRequest._restoreParams(msg.params)
# check if PriorityClass has changed
priorityClass = msg.get('PriorityClass', None)
@@ -950,6 +952,7 @@
# don't handle PersistentRequestRemoved. instead we handle it in Get/PutFailed
+ # ??? why ???
#
#elif msg == message.PersistentRequestRemoved:
# if initialRequest is None:
@@ -1099,12 +1102,12 @@
return False
#TODO:no idea if the node may pass uris with prefixes like 'freenet:'... strip it anyways
- insertURI = key.stripKey(msg['InsertURI'])
- requestURI = key.stripKey(msg['RequestURI'])
+ insertURI = msg['InsertURI']
+ requestURI = msg['RequestURI']
if initialRequest['RequestType'] == consts.RequestType.GenerateUSKKeypair:
- insertURI = insertURI.replace(consts.KeyType.SSK, consts.KeyType.USK, 1)
- requestURI = requestURI.replace(consts.KeyType.SSK, consts.KeyType.USK, 1)
+ insertURI = key.USK(insertURI.keyData, filename=insertURI.filename)
+ requestURI = key.USK(requestURI.keyData, filename=requestURI.filename)
initialRequest['PrivateKey'] = insertURI
initialRequest['PublicKey'] = requestURI
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-06-29 15:19:11
|
Revision: 426
http://fclient.svn.sourceforge.net/fclient/?rev=426&view=rev
Author: jUrner
Date: 2008-06-29 08:19:20 -0700 (Sun, 29 Jun 2008)
Log Message:
-----------
logging
Modified Paths:
--------------
trunk/sandbox/fcp2/client.py
Modified: trunk/sandbox/fcp2/client.py
===================================================================
--- trunk/sandbox/fcp2/client.py 2008-06-29 15:19:09 UTC (rev 425)
+++ trunk/sandbox/fcp2/client.py 2008-06-29 15:19:20 UTC (rev 426)
@@ -288,7 +288,9 @@
##
###############################################################
def _captureEvent(self, event, request):
- if event != self.events.Idle:
+ if event == self.events.Idle:
+ consts.Logger.Event.log(consts.DebugVerbosity.Chatty, consts.LogMessages.EventTriggered + event.name)
+ else:
consts.Logger.Event.info(consts.LogMessages.EventTriggered + event.name)
@@ -1562,7 +1564,6 @@
else:
raise ValueError('Unsupported request type')
- #TODO: autoconvert keys to python classes???
msg = message.MessagesAll[msgName](URI=key)
contentType = msgParams.get('ContentType', None)
if contentType is not None:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-06-29 16:20:54
|
Revision: 428
http://fclient.svn.sourceforge.net/fclient/?rev=428&view=rev
Author: jUrner
Date: 2008-06-29 09:21:01 -0700 (Sun, 29 Jun 2008)
Log Message:
-----------
reworked putData and putRedirect
Modified Paths:
--------------
trunk/sandbox/fcp2/client.py
Modified: trunk/sandbox/fcp2/client.py
===================================================================
--- trunk/sandbox/fcp2/client.py 2008-06-29 15:19:30 UTC (rev 427)
+++ trunk/sandbox/fcp2/client.py 2008-06-29 16:21:01 UTC (rev 428)
@@ -1526,9 +1526,9 @@
def clientPut(self,
requestType,
key,
+ userData,
+ persistentUserData,
data=None,
- persistentUserData='',
- userData=None,
items=None,
**msgParams
):
@@ -1540,7 +1540,7 @@
@param userData: (any) any data to be associated to the request at runtime
@param items: for L{consts.RequestType.PutMultiple}, items to upload
@param msgParams: (dict) Fcp parameters to pass along with the message
-
+
@note: the Fcp message parameter 'Metadata.ContentType' may be passed as 'ContentType'
to this method
@note: to upload multiple items at once pass a dict for each item containig the following members:
@@ -1555,31 +1555,38 @@
All items will be accessible under one single key as 'Uri/Name'. The default item (the item when
only 'Uri' is requested from freenet) is always the first item in the list.
"""
- if requestType in (consts.RequestType.PutData, consts.RequestType.PutFile):
- msgName = message.ClientPut.name
- elif requestType == consts.RequestType.PutDir:
- msgName = message.ClientPutDiskDir.name
- elif requestType == consts.RequestType.PutMultiple:
- msgName = message.ClientPutComplexDir.name
- else:
- raise ValueError('Unsupported request type')
- msg = message.MessagesAll[msgName](URI=key)
+ #FIX: enables passing params as python keywords
contentType = msgParams.get('ContentType', None)
if contentType is not None:
del msgParams['ContentType']
msgParams['Metadata.ContentType'] = contentType
+
+ # find out wich message to use
+ if requestType & (consts.RequestType.PutData | consts.RequestType.PutFile | consts.RequestType.PutRedirect):
+ msgClass = message.ClientPut
+ elif requestType == consts.RequestType.PutDir:
+ msgClass = message.ClientPutDiskDir
+ elif requestType == consts.RequestType.PutMultiple:
+ msgClass = message.ClientPutComplexDir
+ else:
+ raise ValueError('Unsupported request type')
+ msg = msgClass(URI=key)
+
+ # add params
+ if key.KeyType == consts.KeyType.CHK:
+ if key.filename is not None:
+ msg['TargetFilename'] = key.filename
for param, value in msgParams.items():
if value is not None:
msg[param] = value
if data is not None:
if requestType != consts.RequestType.PutData:
- raise ValueError('Data can only be passed along with PutData uploads')
+ raise ValueError('Data can only be passed along with putData uploads')
msg.data = data
if items is not None:
-
if requestType != consts.RequestType.PutMultiple:
raise ValueError('Items can only be passed along with PutMultiple uploads')
@@ -1647,7 +1654,7 @@
if data:
msg.data = data
- #
+ # finally
self._registerRequest(
msg,
requestType,
@@ -1657,7 +1664,7 @@
self.sendMessage(msg)
return msg['Identifier']
-
+ #TESTED
def putData(self,
key,
data,
@@ -1667,20 +1674,43 @@
maxRetries=None,
persistence=consts.Persistence.Connection,
priorityClass=consts.Priority.Medium,
- targetFilename=None,
-
+
userData=None,
persistentUserData='',
):
+ """Uploads data
+ @param key: (L{key.KeyBase}) key under wich to upload the data
+ @param data: (bytes) data to upload
+
+ @param contentType: (str) content type. If not specified, the node will guess the content type
+ @param dontCompress: (bool) if True, the node won't try to compress the data
+ @param maxRetries: (int) maximum number of retries or -1 to retry forver or None to leave it to the node to decide
+ @param priorityClass: (L{consts.Priority}) priority of the request
+
+ @param userData: any non persistent data to associate to the request
+ @param persistentUserData: any string to associate to the request as persistent data
+
+ @event: (L{events.Events.RequestCompleted}) triggered when the request is complete
+ @event: (L{events.Events.RequestFailed}) triggered when the request failes
+ @event: (L{events.Events.RequestFetchable}) triggered as soon as the request is fetchable
+ @event: (L{events.Events.RequestCompressionStarted}) triggered when the request is about to be compressed
+ @event: (L{events.Events.RequestCompressionComopleted}) triggered as soon as compressing of the request is completed
+
+ @note: if the upload is successful the node will create a L{consts.KeyType.CHK} key under wich
+ the data can be retreieved. The key can be accessed as 'URI' member of the request as soon
+ as the L{events.Events.RequestFetchable} or the L{events.Events.RequestCompleted} event
+ is triggered.
+
+ @todo: EarlyEncode and GetCHKOnly message params not implemented
+ """
return self.clientPut(
consts.RequestType.PutData,
key,
-
+ userData,
+ persistentUserData,
data=data,
- persistentUserData=persistentUserData,
- userData=userData,
-
+
# fcp params
ContentType=contentType,
DataLength=len(data),
@@ -1692,16 +1722,14 @@
DontCompress=dontCompress,
Persistence=persistence,
PriorityClass=priorityClass,
- TargetFilename=targetFilename,
UploadFrom=consts.UploadFrom.Direct,
Verbosity=consts.Verbosity.ReportProgress | consts.Verbosity.ReportCompression,
)
-
-
+ #TESTED
def putRedirect(self,
- name,
- targetURI,
+ key,
+ targetKey,
maxRetries=None,
persistence=consts.Persistence.Connection,
priorityClass=consts.Priority.Medium,
@@ -1709,8 +1737,8 @@
persistentUserData='',
):
"""Uploads a redirect to another key
- @param name: name of the redirect
- @param targetURI: (str) uri to redirect to
+ @param key: (L{key.KSK}) to insert as redirect
+ @param targetKey: (key.KeyBase) key to redirect to
@param maxRetries: (int) maximum number of tretries or -1 to leave the decission up to the node
@param persistence: (L{consts.Persistence}) of the request
@param priorityClass: (L{consts.Priority}) priority of the request
@@ -1718,22 +1746,23 @@
@param userData: (any) any data to be associated to the request at runtime
@return: (str) request identifier
"""
- msg = message.ClientPut(
- URI=consts.KeyType.KSK + name,
- Persistence=persistence,
- PriorityClass=priorityClass,
- TargetURI=targetURI,
- UploadFrom=consts.UploadFrom.Redirect,
- )
- self._registerRequest(
- msg,
- consts.RequestType.PutRedirect,
- persistentUserData=persistentUserData,
- userData=userData,
- )
- self.sendMessage(msg)
- return msg['Identifier']
+ return self.clientPut(
+ consts.RequestType.PutRedirect,
+ key,
+ userData,
+ persistentUserData,
+ Persistence=persistence,
+ PriorityClass=priorityClass,
+ TargetURI=targetKey,
+ UploadFrom=consts.UploadFrom.Redirect,
+ )
+ #########################################################
+ #########################################################
+ #########################################################
+ #########################################################
+ #########################################################
+
#CHK
def chkPutData(self,
data,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-06-30 08:56:40
|
Revision: 432
http://fclient.svn.sourceforge.net/fclient/?rev=432&view=rev
Author: jUrner
Date: 2008-06-30 01:56:39 -0700 (Mon, 30 Jun 2008)
Log Message:
-----------
all methods now have a test case
++ some fixes
Modified Paths:
--------------
trunk/sandbox/fcp2/client.py
Modified: trunk/sandbox/fcp2/client.py
===================================================================
--- trunk/sandbox/fcp2/client.py 2008-06-30 08:55:28 UTC (rev 431)
+++ trunk/sandbox/fcp2/client.py 2008-06-30 08:56:39 UTC (rev 432)
@@ -431,7 +431,6 @@
## connection related methods
##
###############################################################
- #TESTED
def close(self):
"""Closes the client
@note: make shure to call close() when done with the client
@@ -441,7 +440,7 @@
)
self._close(msg)
- #TESTED
+
def closeNode(self):
"""Shuts down the freenet node"""
self.sendMessage(message.Shutdown())
@@ -461,7 +460,7 @@
pass
return nodeHello
- #TESTED
+
def isOpen(self):
"""Checks if the clients connection is open
@return: (bool) True if so, False otherwise
@@ -469,7 +468,7 @@
return self.ioHandler.isOpen()
- #TESTED
+
def iterConnect(self, host=DefaultFcpHost, port=DefaultFcpPort, duration=20, timeout=0.5):
"""Iterator to stablish a connection to a freenet node
@param host: (str) host of th node
@@ -532,14 +531,14 @@
self._close(disconnectMsg)
raise StopIteration
- #TESTED
+
def getConnectionName(self):
"""Returns the connection name used by the client
@return: (str) connection name
"""
return self._connectionName
- #TESTED
+
def setConnectionName(self, connectionName=None):
"""Sets the connection name to be used by the client
@param connectionName: (str) connection name or None to use an arbitrary connection name
@@ -548,7 +547,7 @@
self._connectionName = self._newUuid() if connectionName is None else connectionName
return self._connectionName
- #TESTED
+
def getDebugVerbosity(self):
"""Returns the current verbosity level of the client
@return: L{consts.DebugVerbosity}
@@ -556,7 +555,7 @@
return consts.Logger.Client.getEffectiveLevel()
- #TESTED
+
def setDebugVerbosity(self, debugVerbosity):
"""Sets the verbosity level of the client
@param debugVerbosity: L{consts.DebugVerbosity}
@@ -564,7 +563,7 @@
consts.Logger.Client.setLevel(debugVerbosity)
- #TESTED
+
def startNode(self, cmdline):
"""Starts the freenet node
@param cmdline: commandline to start freenet (like '/freenet/run.sh start' or 'c:\freenet\start.bat')
@@ -581,7 +580,7 @@
stdout, stderr = p.communicate()
return stdout
- #TESTED
+
def versionCheckNodeHello(self, nodeHelloMessage):
"""Performa a version check of the client against the specified NodeHello message
@return: (bool) True if version is ok, False otherwise
@@ -598,7 +597,6 @@
## runtime related methods
##
#########################################################
- #TESTED
def handleMessage(self, msg):
"""Handles a message from the freenet node
@param msg: (Message) to handle
@@ -952,19 +950,16 @@
self.events.RequestModified(initialRequest)
return True
-
- # don't handle PersistentRequestRemoved. instead we handle it in Get/PutFailed
- # ??? why ???
- #
- #elif msg == message.PersistentRequestRemoved:
- # if initialRequest is None:
- # return False
+ #NOTE: fcp sends a GetFailed / PutFailed if the request was still running (code=canceled)
+ elif msg == message.PersistentRequestRemoved:
+ if initialRequest is None:
+ return False
- # initialRequest['RequestStatus'] |= consts.RequestStatus.Removed
- # self._finalizeRequest(msg, initialRequest, self.events.RequestRemoved)
- # return True
-
-
+ initialRequest['RequestStatus'] |= consts.RequestStatus.Removed | consts.RequestStatus.Completed | consts.RequestStatus.RemovedFromQueue
+ del self._requests[requestIdentifier]
+ self.events.RequestRemoved(initialRequest)
+ return True
+
elif msg == message.SimpleProgress:
if initialRequest is None:
return False
@@ -1103,16 +1098,14 @@
if initialRequest is None:
return False
- #TODO:no idea if the node may pass uris with prefixes like 'freenet:'... strip it anyways
insertURI = msg['InsertURI']
requestURI = msg['RequestURI']
if initialRequest['RequestType'] == consts.RequestType.GenerateUSKKeypair:
insertURI = key.USK(insertURI.keyData, filename=insertURI.filename)
requestURI = key.USK(requestURI.keyData, filename=requestURI.filename)
-
- initialRequest['PrivateKey'] = insertURI
- initialRequest['PublicKey'] = requestURI
+ initialRequest['InsertURI'] = insertURI
+ initialRequest['RequestURI'] = requestURI
initialRequest['RequestStatus'] |= consts.RequestStatus.Success
self._finalizeRequest(msg, initialRequest, self.events.KeypairGenerated)
return True
@@ -1129,7 +1122,7 @@
# default
return False
- #TESTED
+
def next(self, dispatch=True):
"""Pumps the next message waiting
@param dispatch: if True the message is dispatched to L{handleMessage}
@@ -1153,7 +1146,7 @@
self.handleMessage(msg)
return msg
- #TESTED
+
def run(self):
"""Runs the client unconditionally untill all requests have completed
@note: a KeyboardInterrupt will stop the client
@@ -1196,7 +1189,7 @@
if msg == message.ClientSocketDied:
break
- #TESTED
+
def sendMessage(self, msg):
"""Sends a message to freenet
@param msg: (L{message.Message}) message to send
@@ -1225,7 +1218,6 @@
## config related methods
##
#########################################################
- #TESTED
def getConfig(self,
withCurrent=True,
withDefaults=True,
@@ -1253,7 +1245,7 @@
)
- #TESTED
+
def modifyConfig(self, params):
"""Modifies node configuration values
@param params: (dict) containing parameters to modify
@@ -1268,7 +1260,7 @@
##
########################################################
def clientGet(self,
- key,
+ uri,
requestType,
userData,
persistentUserData,
@@ -1276,7 +1268,7 @@
**messageParams
):
"""Requests a key from the node
- @param key: (L{key.KeyBase}) key to request
+ @param uri: (L{key.KeyBase}) key to request
@param requestType: (L{consts.RequestType}) sub type of the message
@param userData: any non persistent data to associate to the request or None
@param persistentUserData: any string to associate to the request as persistent data or None
@@ -1286,7 +1278,7 @@
@return: (str) request identifier
"""
- msg = message.ClientGet(URI=key)
+ msg = message.ClientGet(URI=uri)
for paramName, value in messageParams.items():
if value is not None:
msg[paramName] = value
@@ -1302,9 +1294,9 @@
return msg['Identifier']
- #TESTED
+
def getData(self,
- key,
+ uri,
allowedMimeTypes=None,
binaryBlob=False,
@@ -1320,7 +1312,7 @@
):
"""Requests datae from the node
- @param key: (L{key.KeyBase}) key to request
+ @param uri: (L{key.KeyBase}) key to request
@param allowedMimeTypes: (str) list of allowed mime types
@param binaryBlob: (bool) if True, the file is retrieved as binary blob file
@@ -1346,7 +1338,7 @@
as soon as it completes or failes
"""
return self.clientGet(
- key,
+ uri,
consts.RequestType.GetData,
userData,
persistentUserData,
@@ -1368,9 +1360,9 @@
)
- #TESTED
+
def getFile(self,
- key,
+ uri,
filename,
allowedMimeTypes=None,
@@ -1388,7 +1380,7 @@
):
"""Requests a file from the node
- @param key: (L{key.KeyBase}) key to request
+ @param uri: (L{key.KeyBase}) key to request
@param filename: (full path) filename to store the file to
@param allowedMimeTypes: (str) list of allowed mime types
@@ -1415,7 +1407,7 @@
as soon as it completes or failes
"""
return self.clientGet(
- key,
+ uri,
consts.RequestType.GetFile,
userData,
persistentUserData,
@@ -1438,9 +1430,9 @@
)
- #TESTED
+
def getKeyInfo(self,
- key,
+ uri,
dsOnly=False,
ignoreDS=False,
@@ -1453,7 +1445,7 @@
):
"""Requests info about a key
- @param key: (L{key.KeyBase}) key to request
+ @param uri: (L{key.KeyBase}) key to request
@param dsOnly: if True, retrieves the file from the local data store only
@param ignoreDS: If True, ignores the local data store
@@ -1476,7 +1468,7 @@
"""
# how to retrieve meta info about a key? ...idea is to provoke a GetFailed (TooBig)
return self.clientGet(
- key,
+ uri,
consts.RequestType.GetKeyInfo,
userData,
persistentUserData,
@@ -1496,8 +1488,8 @@
)
- #TESTED
- def subscribeUSK(self, key, dontPoll=True):
+
+ def subscribeUSK(self, uri, dontPoll=True):
"""Asks the node to notify the client when an USK is updated
@param key: (L{key.USK}) key to subscribe to
@param dontPoll: if True, does whatever ???
@@ -1509,7 +1501,7 @@
@todo: looks like USK subscribes will persist untill connection is closed. Can they be removed somehow?
"""
msg = message.SubscribeUSK(
- URI=key,
+ URI=uri,
DontPoll=dontPoll,
)
self._registerRequest(msg, consts.RequestType.SubscribeUSK)
@@ -1525,7 +1517,7 @@
########################################################
def clientPut(self,
requestType,
- key,
+ uri,
userData,
persistentUserData,
data=None,
@@ -1534,7 +1526,7 @@
):
"""Uploads to the node
@param requestType: (L{consts.RequestType}). Can be PutData, PutDir or PutMultiple
- @param key: (str) key or Uri
+ @param uri: (str) key or Uri
@param data: (str) for L{consts.RequestType.PutData} data to upload or None
@param persistentUserData: (str) persistent data to be assosiated to the request
@param userData: (any) any data to be associated to the request at runtime
@@ -1571,12 +1563,12 @@
msgClass = message.ClientPutComplexDir
else:
raise ValueError('Unsupported request type')
- msg = msgClass(URI=key)
+ msg = msgClass(URI=uri)
# add params
- if key.KeyType == consts.KeyType.CHK:
- if key.filename is not None:
- msg['TargetFilename'] = key.filename
+ if uri.KeyType == consts.KeyType.CHK:
+ if uri.filename is not None:
+ msg['TargetFilename'] = uri.filename
for param, value in msgParams.items():
if value is not None:
msg[param] = value
@@ -1664,9 +1656,9 @@
self.sendMessage(msg)
return msg['Identifier']
- #TESTED
+
def putData(self,
- key,
+ uri,
data,
contentType=None,
@@ -1680,7 +1672,7 @@
):
"""Uploads data
- @param key: (L{key.KeyBase}) key under wich to upload the data
+ @param uri: (L{key.KeyBase}) key under wich to upload the data
@param data: (bytes) data to upload
@param contentType: (str) content type. If not specified, the node will guess the content type
@@ -1695,7 +1687,7 @@
@event: (L{events.Events.RequestFailed}) triggered when the request failes
@event: (L{events.Events.RequestFetchable}) triggered as soon as the request is fetchable
@event: (L{events.Events.RequestCompressionStarted}) triggered when the request is about to be compressed
- @event: (L{events.Events.RequestCompressionComopleted}) triggered as soon as compressing of the request is completed
+ @event: (L{events.Events.RequestCompressionCompleted}) triggered as soon as compressing of the request is completed
@note: if the upload is successful the node will create a L{consts.KeyType.CHK} key under wich
the data can be retreieved. The key can be accessed as 'URI' member of the request as soon
@@ -1706,7 +1698,7 @@
"""
return self.clientPut(
consts.RequestType.PutData,
- key,
+ uri,
userData,
persistentUserData,
data=data,
@@ -1726,114 +1718,15 @@
Verbosity=consts.Verbosity.ReportProgress | consts.Verbosity.ReportCompression,
)
- #TESTED
- def putRedirect(self,
- key,
- targetKey,
- maxRetries=None,
- persistence=consts.Persistence.Connection,
- priorityClass=consts.Priority.Medium,
- userData=None,
- persistentUserData='',
- ):
- """Uploads a redirect to another key
- @param key: (L{key.KSK}) to insert as redirect
- @param targetKey: (key.KeyBase) key to redirect to
- @param maxRetries: (int) maximum number of tretries or -1 to leave the decission up to the node
- @param persistence: (L{consts.Persistence}) of the request
- @param priorityClass: (L{consts.Priority}) priority of the request
- @param persistentUserData: (str) persistent data to be assosiated to the request
- @param userData: (any) any data to be associated to the request at runtime
- @return: (str) request identifier
- """
- return self.clientPut(
- consts.RequestType.PutRedirect,
- key,
- userData,
- persistentUserData,
- Persistence=persistence,
- PriorityClass=priorityClass,
- TargetURI=targetKey,
- UploadFrom=consts.UploadFrom.Redirect,
- )
- #########################################################
- #########################################################
- #########################################################
- #########################################################
- #########################################################
-
- #CHK
- def chkPutData(self,
- data,
-
- contentType=None,
- dontCompress=None,
- maxRetries=None,
- persistence=consts.Persistence.Connection,
- priorityClass=consts.Priority.Medium,
- targetFilename=None,
-
- userData=None,
- persistentUserData='',
- ):
- """Uploads data
- @param data: (bytes) data to upload
-
- @param contentType: (str) content type. If not specified, the node will guess the content type
- @param dontCompress: (bool) if True, the node won't try to compress the data
- @param maxRetries: (int) maximum number of retries or -1 to retry forver or None to leave it to the node to decide
- @param priorityClass: (L{consts.Priority}) priority of the request
- @param targetFilename: (str) filename to append to the key (may not contain slashes)
-
- @param userData: any non persistent data to associate to the request
- @param persistentUserData: any string to associate to the request as persistent data
-
- @event: (L{events.Events.RequestCompleted}) triggered when the request is complete
- @event: (L{events.Events.RequestFailed}) triggered when the request failes
- @event: (L{events.Events.RequestFetchable}) triggered as soon as the request is fetchable
- @event: (L{events.Events.RequestCompressionStarted}) triggered when the request is about to be compressed
- @event: (L{events.Events.RequestCompressionComopleted}) triggered as soon as compressing of the request is completed
-
- @note: if the upload is successful the node will create a L{consts.KeyType.CHK} key under wich
- the data can be retreieved. The key can be accessed as 'URI' member of the request as soon
- as the L{events.Events.RequestFetchable} or the L{events.Events.RequestCompleted} event
- is triggered.
-
- @todo: EarlyEncode and GetCHKOnly message params not implemented
- """
- return self.clientPut(
- consts.RequestType.PutData,
- consts.KeyType.CHK,
-
- data=data,
- persistentUserData=persistentUserData,
- userData=userData,
-
- # fcp params
- ContentType=contentType,
- DataLength=len(data),
- #EarlyEncode='false',
- #GetCHKOnly='false',
- Global=False,
- Identifier=None,
- MaxRetries=maxRetries,
- DontCompress=dontCompress,
- Persistence=persistence,
- PriorityClass=priorityClass,
- TargetFilename=targetFilename,
- UploadFrom=consts.UploadFrom.Direct,
- Verbosity=consts.Verbosity.ReportProgress | consts.Verbosity.ReportCompression,
- )
-
-
- def chkPutDir(self,
+ def putDir(self,
+ uri,
directory,
allowUnreadableFiles=False,
-
+ defaultName=None,
contentType=None,
+
dontCompress=None,
- defaultName=None,
maxRetries=None,
persistence=consts.Persistence.Connection,
priorityClass=consts.Priority.Medium,
@@ -1845,11 +1738,14 @@
):
"""Uploads the contents of a directory
+ @param uri: (L{key.KeyBase}) key under wich to upload the directory
@param directory: (str) directory to upload
@param allowUnreadableFiles: if True, unreadable files in the directory are ignored, if False the request fails
- if it encounters an unreadavle file.
+ if it encounters an unreadavle file
+ @param defaultName: name of the directory item that should be displayed when accessing the directory
+ without any filename appended to the uri
- @note: for other params see L{chkPutData}
+ @note: for other params see L{putData}
@note: once uploaded, items of the directory can be accessed under Key/MyItemName/MyItemSubname
@todo: EarlyEncode and GetCHKOnly message params not implemented
@@ -1857,18 +1753,15 @@
"""
return self.clientPut(
consts.RequestType.PutDir,
- consts.KeyType.CHK,
-
- data=None,
- persistentUserData=persistentUserData,
- userData=userData,
-
+ uri,
+ userData,
+ persistentUserData,
+
# fcp params
- Filename=directory,
- AllowUnreadableFiles=allowUnreadableFiles,
ContentType=contentType,
DefaultName=defaultName,
#EarlyEncode='false',
+ Filename=directory,
#GetCHKOnly='false',
Global=False,
Identifier=None,
@@ -1876,44 +1769,42 @@
DontCompress=dontCompress,
Persistence=persistence,
PriorityClass=priorityClass,
- TargetFilename=targetFilename,
UploadFrom=consts.UploadFrom.Disk,
Verbosity=consts.Verbosity.ReportProgress | consts.Verbosity.ReportCompression,
)
-
- def chkPutFile(self,
+
+ def putFile(self,
+ uri,
filename,
contentType=None,
dontCompress=None,
maxRetries=None,
persistence=consts.Persistence.Connection,
priorityClass=consts.Priority.Medium,
- targetFilename=None,
-
+
userData=None,
persistentUserData='',
):
"""Uploads a file
- @param filename: (bytes) data to upload
+ @param uri: (L{key.KeyBase}) key under wich to upload the file
+ @param filename: (str) file to upload
- @note: for other params see L{chkPutData}
+ @note: for other params see L{putData}
@todo: EarlyEncode and GetCHKOnly message params not implemented
"""
return self.clientPut(
consts.RequestType.PutFile,
- consts.KeyType.CHK,
-
- data=None,
- persistentUserData=persistentUserData,
- userData=userData,
-
+ uri,
+ userData,
+ persistentUserData,
+
# fcp params
- Filename=filename,
ContentType=contentType,
- #EarlyEncode='false',
+ #EarlyEncode='false',
+ Filename=filename,
#GetCHKOnly='false',
Global=False,
Identifier=None,
@@ -1921,18 +1812,14 @@
DontCompress=dontCompress,
Persistence=persistence,
PriorityClass=priorityClass,
- TargetFilename=targetFilename,
UploadFrom=consts.UploadFrom.Disk,
Verbosity=consts.Verbosity.ReportProgress | consts.Verbosity.ReportCompression,
)
-
-
- def chkPutMultiple(self,
+ def putMultiple(self,
+ uri,
items,
- allowUnreadableFiles=False,
- contentType=None,
defaultName=None,
dontCompress=None,
maxRetries=None,
@@ -1946,9 +1833,10 @@
):
"""Uploads multiple items at once to be retrievable under one key
+ @param uri: (L{key.KeyBase}) key under wich to upload the file
@param items: (list) list of items to upload
- @note: for other params see L{chkPutData}
+ @note: for other params see L{chkPutDir}
@note: to upload multiple items at once pass a dict for each item containig the following members:
- RequestType: L{consts.RequestType.PutData}, L{consts.RequestType.PutFile} or L{consts.RequestType.PutRedirect}
@@ -1966,16 +1854,12 @@
"""
return self.clientPut(
consts.RequestType.PutMultiple,
- consts.KeyType.CHK,
-
- data=None,
- persistentUserData=persistentUserData,
- userData=userData,
+ uri,
+ userData,
+ persistentUserData,
items=items,
-
+
# fcp params
- AllowUnreadableFiles=allowUnreadableFiles,
- ContentType=contentType,
DefaultName=defaultName,
#EarlyEncode='false',
#GetCHKOnly='false',
@@ -1985,132 +1869,42 @@
DontCompress=dontCompress,
Persistence=persistence,
PriorityClass=priorityClass,
- TargetFilename=targetFilename,
UploadFrom=consts.UploadFrom.Disk,
Verbosity=consts.Verbosity.ReportProgress | consts.Verbosity.ReportCompression,
)
- ########################################################
- ##
- ## SSK ClientPut related methods
- ##
- ########################################################
- def sskPutData(self,
- data,
- privateKey,
-
- contentType=None,
- dontCompress=None,
- maxRetries=None,
- persistence=consts.Persistence.Connection,
- priorityClass=consts.Priority.Medium,
- targetFilename=None,
-
- userData=None,
- persistentUserData='',
- ):
- """Uploads data that can be updated by the owner
- @param data: (bytes) data to upload
- @param privateKey: see: private key as generated by L{generateKeypair} + '/' + name
-
- @note: for other params see L{chkPutData}
- @note: use this method to upload updatable data. First you need to create a public / private
- keypair. The private key is used for uploading, the public key for retrieving the data.
- You should add a name to the keypairs like: "privateKey/MyData" and "publicKey/MyData".
- This may aswell be used to implement a basic edition scheme: "privateKey/MyEdition-0",
- "privateKey/MyEdition-1"
- """
- return self.clientPut(
- consts.RequestType.PutData,
- privateKey,
-
- data=data,
- persistentUserData=persistentUserData,
- userData=userData,
-
- # fcp params
- ContentType=contentType,
- DataLength=len(data),
-
- #EarlyEncode='false',
- #GetCHKOnly='false',
- Global=False,
- Identifier=None,
- MaxRetries=maxRetries,
- DontCompress=dontCompress,
- Persistence=persistence,
- PriorityClass=priorityClass,
- UploadFrom=consts.UploadFrom.Direct,
- Verbosity=consts.Verbosity.ReportProgress | consts.Verbosity.ReportCompression,
- )
-
- def sskPutDir(self):
- pass
- def sskPutFile(self):
- pass
-
- def sskPutMultiple(self):
- pass
-
- ########################################################
- ##
- ## USK ClientPut related methods
- ##
- ########################################################
- def uskPutData(self,
- data,
- privateKey,
-
- contentType=None,
- dontCompress=None,
+ def putRedirect(self,
+ uri,
+ targetKey,
maxRetries=None,
persistence=consts.Persistence.Connection,
priorityClass=consts.Priority.Medium,
- targetFilename=None,
-
userData=None,
- persistentUserData=''
+ persistentUserData='',
):
- """Uploads data
-
+ """Uploads a redirect to another key
+ @param uri: (L{key.KSK}) to insert as redirect
+ @param targetKey: (key.KeyBase) key to redirect to
+ @param maxRetries: (int) maximum number of tretries or -1 to leave the decission up to the node
+ @param persistence: (L{consts.Persistence}) of the request
+ @param priorityClass: (L{consts.Priority}) priority of the request
+ @param persistentUserData: (str) persistent data to be assosiated to the request
+ @param userData: (any) any data to be associated to the request at runtime
+ @return: (str) request identifier
"""
-
-
return self.clientPut(
- consts.RequestType.PutData,
- privateKey,
- #insertURI + 'foo/0/',
- userData=userData,
- persistentUserData=persistentUserData,
- data=data,
-
- # fcp params
- ContentType=contentType,
- DataLength=len(data),
- #EarlyEncode='false',
- #GetCHKOnly='false',
- Global=False,
- Identifier=None,
- MaxRetries=maxRetries,
- DontCompress=dontCompress,
- Persistence=persistence,
- TargetFilename=targetFilename,
- UploadFrom=consts.UploadFrom.Direct,
- Verbosity=consts.Verbosity.ReportProgress | consts.Verbosity.ReportCompression,
- )
-
- def uskPutDir(self):
- pass
+ consts.RequestType.PutRedirect,
+ uri,
+ userData,
+ persistentUserData,
+ Persistence=persistence,
+ PriorityClass=priorityClass,
+ TargetURI=targetKey,
+ UploadFrom=consts.UploadFrom.Redirect,
+ )
- def uskPutFile(self):
- pass
-
-
- def uskPutMultiple(self):
- pass
-
########################################################
##
## request related methods
@@ -2198,66 +1992,6 @@
del self._requests[requestIdentifier]
- def resendRequest(self, request):
- """Resends a request
- @param request: (L{message.Message})
- @return: (str) request identifier
-
- @note: you can use this method to resend get / put requests.All attempts to resend other requests
- will fail
- @note: actually a new request is created and registered. Todo so, the request passed is copied. If it is a persistent
- request, it will be removed. The new request will have FcInitTime reset and FcUserData amd FcPersistentUserData
- taken over from the old request
-
- @note: for SSK and USK puts, the private key is taken from request['PrivateKey']. Adjust private (and public
- key) if necessary
-
- @todo: reset init time or not? Currently it is not reset.
- """
- requestType = request.get('RequestType', consts.RequestType.Null)
- if not requestType & (consts.RequestType.MaskGet | consts.RequestType.MaskPut):
- raise ValueError('Can not resend request: %s' % request.name)
-
- # we don't know what UserData may be, so back it up before copying
- oldIdentifier = request['Identifier']
- oldUserData, request['UserData'] = request['UserData'], None
- newRequest = copy.deepcopy(request)
-
- # reset key if necessary
- if requestType & consts.RequestType.MaskPut:
- requestKey = key.KeyBase.fcpToPython(request['URI'])
- if requestKey is None:
- raise ValueError('Ups, URI of the request seems not to be valid')
-
- if requestKey.KeyType == consts.KeyType.CHK:
- newRequest['URI'] = consts.KeyType.CHK
- elif requestKey.KeyType == consts.KeyType.SSK:
- newRequest['URI'] = request['PrivateKey']
- if requestKey.filename:
- newRequest['URI'] += '/' + requestKey.filename
- elif requestKey.KeyType == consts.KeyType.USK:
- newRequest['URI'] = request['PrivateKey']
- if requestKey.filename:
- newRequest['URI'] += '/' + requestKey.filename
-
-
- filenameCollision = newRequest.get('FilenameCollision', None)
- self._registerRequest(
- newRequest,
- requestType,
- filenameCollision= None if filenameCollision is None else filenameCollision & consts.FilenameCollision.MaskHandle,
- #initTime=time.time(),
- persistentUserData=newRequest['PersistentUserData'],
- userData=oldUserData,
- )
-
- if oldIdentifier in self._requests:
- request['UserData'] = oldUserData
- self.removeRequest(request['Identifier'])
-
- self.sendMessage(newRequest)
- return newRequest['Identifier']
-
########################################################
##
## Peer related methods
@@ -2402,7 +2136,7 @@
@return: (L{message.FCPPluginMessage})
@note: the client does not keep track of messages send to a plugin, because the plugin
- may or may not return. If the plugin sends a reply, a L{events.PluginMessage} is triggered.
+ may or may not return. If the plugin sends a reply, a L{events.Events.PluginMessage} is triggered.
If something goes wrong, L{events.Events.ProtocolError} or an is L{events.Events.IdentifierCollision}
is triggered. Use the identifier passed to identify responses.
@@ -2434,7 +2168,7 @@
@event: L{events.Events.KeypairGenerated} triggered as soon as the request is complete
"""
if keypairType not in (consts.KeyType.SSK, consts.KeyType.USK):
- raise ValueError('keypairType must be %s or %s' % (consts.KeyType.SSK, consts.KeyType.USK))
+ raise ValueError('keypairType must be SSK or USK')
requestType = consts.RequestType.GenerateSSKKeypair if keypairType == consts.KeyType.SSK else consts.RequestType.GenerateUSKKeypair
msg = message.GenerateSSK()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-06-30 09:12:43
|
Revision: 436
http://fclient.svn.sourceforge.net/fclient/?rev=436&view=rev
Author: jUrner
Date: 2008-06-30 02:12:16 -0700 (Mon, 30 Jun 2008)
Log Message:
-----------
fix for PutDiskDir vs PutComplexDir on restore
Modified Paths:
--------------
trunk/sandbox/fcp2/client.py
Modified: trunk/sandbox/fcp2/client.py
===================================================================
--- trunk/sandbox/fcp2/client.py 2008-06-30 08:58:39 UTC (rev 435)
+++ trunk/sandbox/fcp2/client.py 2008-06-30 09:12:16 UTC (rev 436)
@@ -876,7 +876,6 @@
# unknown request... try to restore it
if initialRequest is None:
-
if CancelPersistentRequests:
self.sendMessage(
message.RemovePersistentRequest(
@@ -891,22 +890,16 @@
requestType = msg['RequestType']
if requestType & consts.RequestType.MaskGet:
initialRequest = message.ClientGet()
-
- #FIXME: does not work as expected
- # ClientPutdiskDir is just a subtype of ClientPutComplexDir
- # items will be passed as Files.N.* container
-
- elif requestType == consts.RequestType.PutMultiple:
+ elif requestType & (onsts.RequestType.PutDir | consts.RequestType.PutMultiple):
+ #NOTE: PutDiskDir is just a subtype of PutComplexDir
initialRequest = message.ClientPutComplexDir()
- elif requestType == consts.RequestType.PutDir:
- initialRequest = message.ClientPutdiskDir()
else:
initialRequest = message.ClientPut()
initialRequest.params.update(msg.params)
self._requests[initialRequest['Identifier']] = initialRequest
- #FIX: remove Started param from PersistentGet / Put
+ #FIX: remove Started param from PersistentGet / Put, not interesting
if 'Started' in initialRequest.params:
del initialRequest.params['Started']
initialRequest['RequestStatus'] |= consts.RequestStatus.Restored
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-06-30 09:17:19
|
Revision: 437
http://fclient.svn.sourceforge.net/fclient/?rev=437&view=rev
Author: jUrner
Date: 2008-06-30 02:17:24 -0700 (Mon, 30 Jun 2008)
Log Message:
-----------
...
Modified Paths:
--------------
trunk/sandbox/fcp2/client.py
Modified: trunk/sandbox/fcp2/client.py
===================================================================
--- trunk/sandbox/fcp2/client.py 2008-06-30 09:12:16 UTC (rev 436)
+++ trunk/sandbox/fcp2/client.py 2008-06-30 09:17:24 UTC (rev 437)
@@ -885,8 +885,6 @@
)
return True
- #NOTE: there is no distinction between ClientPutDiskDir and ClientPutComplexDir
- # so a bit of additional work here
requestType = msg['RequestType']
if requestType & consts.RequestType.MaskGet:
initialRequest = message.ClientGet()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|