SF.net SVN: fclient: [287] trunk/sandbox/fcp2/client.py
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <ju...@us...> - 2008-02-27 12:06:09
|
Revision: 287
http://fclient.svn.sourceforge.net/fclient/?rev=287&view=rev
Author: jurner
Date: 2008-02-27 04:05:55 -0800 (Wed, 27 Feb 2008)
Log Message:
-----------
combed over docs
Modified Paths:
--------------
trunk/sandbox/fcp2/client.py
Modified: trunk/sandbox/fcp2/client.py
===================================================================
--- trunk/sandbox/fcp2/client.py 2008-02-27 00:13:21 UTC (rev 286)
+++ trunk/sandbox/fcp2/client.py 2008-02-27 12:05:55 UTC (rev 287)
@@ -201,6 +201,7 @@
from fcp2 import events
from fcp2 import message
from fcp2 import fcparams
+from fcp2 import types
from fcp2 import uri
from fcp2.fcp_lib import namespace
@@ -217,16 +218,18 @@
class Client(object):
"""
@ivar events: events the client supports
+
+
+ @todo: cvar MaxSizeKeyInfo. Check if required.
+ suggested by Mathew Toseland to use about 32k for mimeType requests
+ basic sizes of keys are: 1k for SSks and 32k for CHKs without MaxSize
+ DataFound will have DataLength set to 0 (?!)
+
"""
ExpectedFcpVersion = 2.0
ExpectedNodeBuild = 1107
DefaultFcpHost = os.environ.get('FCP_HOST', '127.0.0.1')
DefaultFcpPort = int(os.environ.get('FCP_PORT', '9481'))
-
- #TODO: check if required
- # suggested by Mathew Toseland to use about 32k for mimeType requests
- # basic sizes of keys are: 1k for SSks and 32k for CHKs
- # without MaxSize DataFound will have DataLength set to 0 (?!)
MaxSizeKeyInfo = 32768
MinimumRunTime = 1 # minimum time (seconds) the client will run when run() is called (FIX: 0001931)
SocketTimeout = 0.1
@@ -235,6 +238,7 @@
config = config
message = message
fcparams = fcparams
+ types = types
Uri = uri
@@ -277,6 +281,8 @@
def _close(self, msg):
"""Closes the client
@param msg: message to pass to the ClientDisconnected event or None to not inform listeners
+
+ @todo: complain if the client is already closed?
"""
self._loggers['Runtime'].info(consts.LogMessages.ClientClose)
@@ -289,7 +295,7 @@
self._requests = {}
if self._socket is None:
- #TODO: complain or not?
+ # complain or not?
pass
else:
self._socket.close()
@@ -574,8 +580,9 @@
"""Starts freenet
@param cmdline: commandline to start freenet (like '/freenet/run.sh start' or 'c:\freenet\start.bat')
@return: (str) whatever freenet returns
+
+ @todo: on windows it may be necessary to hide the command window
"""
- #TODO: on windows it may be necessary to hide the command window
p = subprocess.Popen(
args=cmdline,
shell=True,
@@ -706,7 +713,6 @@
self._finalizeRequest(msg, initialRequest, self.events.PluginInfoFailed)
return True
- # TODO: just a guess that FCPPluginMessage can trigger an AccessDenied error
elif initialRequest.name == consts.Message.FCPPluginMessage:
initialRequest['FcErrorMessage'] = msg
initialRequest['FcRequestStatus'] |= consts.RequestStatus.Error
@@ -796,7 +802,6 @@
testFailed = not msg.params.get('ReadDirectoryAllowed', False)
if testFailed:
- #TODO: check if errorMsg gives reasonable feedback
initialRequest['FcRequestStatus'] = consts.RequestStatus.Error
initialRequest['FcErrorMessage'] = initialRequest['FcTestDDA']['ErrorMsg']
self._finalizeRequest(msg, initialRequest, self.events.RequestFailed)
@@ -937,6 +942,10 @@
# ...as long as no other param is changed at runtime we are ok
# otherwise we would have to set flags to indicate wich member
# of ClientToken changed. See --> modifyRequest()
+ #
+ # hmm ..thinking again, this would only work if we could make shure
+ # PersistentUserData can only be modified through modifyRequest().
+ # So no way.
modified[consts.RequestModified.PersistentUserData] = None
for i, fcParam in enumerate(fcparams.FcParams):
initialRequest[fcParam] = params[i]
@@ -1557,8 +1566,6 @@
)
-
- #TODO: persists until connection is closed... can this request be removed?
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
@@ -1567,6 +1574,8 @@
@note: this request can not be removed or modified and the {consts.RequestStatus.Completed}
flag is always set
+
+ @todo: looks like USK subscribes will persist untill connection is closed. Can they be removed somehow?
"""
msg = message.Message(
consts.Message.SubscribeUSK,
@@ -2013,6 +2022,8 @@
@note: you can not change the priority of requests with Persistence=L{consts.Persistence.Connection}.
All attempts to do so are ignored. Too bad, but doing so is not implemented in the client protocol.
+ @todo: currently we ignore any attempts to change priority class for requests with persistence == connection
+ Fcp does not provide means to do so.
"""
initialRequest = self._requests[requestIdentifier]
if not initialRequest['FcRequestType'] & (consts.RequestType.MaskGet | consts.RequestType.MaskPut):
@@ -2022,8 +2033,6 @@
# no way to change priority here ..this is simply not implemented in the protocol
if initialRequest['Persistence'] == consts.Persistence.Connection:
modified = {}
-
- #TODO: currently we ignore any attempts to change priority class
#if priorityClass is not None:
# raise ValueError('Can not modify priority of requests with Persistence=connection')
@@ -2072,10 +2081,7 @@
else:
del self._requests[requestIdentifier]
- #TODO: check how Fcp responds when the identifier is unknown or something else goes
- # werong. Maybe a ProtocolError.NoSuchIdentifier ??? Naa ...never seen this
-
-
+
def resendRequest(self, request):
"""Resends a request
@param request: (L{message.Message})
@@ -2086,6 +2092,8 @@
@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
+
+ @todo: reset init time or not? Currently it is not reset.
"""
requestType = request.get('FcRequestType', consts.RequestType.Null)
if not requestType & (consts.RequestType.MaskGet | consts.RequestType.MaskPut):
@@ -2101,7 +2109,7 @@
newRequest,
requestType,
filenameCollision=newRequest['FcFilenameCollision'] & consts.FilenameCollision.MaskHandle,
- #initTime=time.time(), # TODO: reset init time or not?
+ #initTime=time.time(),
persistentUserData=newRequest['FcPersistentUserData'],
userData=oldUserData,
)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|