SF.net SVN: fclient: [198] trunk/sandbox/fcp/fcp2_0_client.py
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <ju...@us...> - 2008-02-09 18:03:38
|
Revision: 198
http://fclient.svn.sourceforge.net/fclient/?rev=198&view=rev
Author: jurner
Date: 2008-02-09 10:03:38 -0800 (Sat, 09 Feb 2008)
Log Message:
-----------
fix: PriorityClass can not be changed for requests with Persistence=connection.
This is not possible Fcp
Modified Paths:
--------------
trunk/sandbox/fcp/fcp2_0_client.py
Modified: trunk/sandbox/fcp/fcp2_0_client.py
===================================================================
--- trunk/sandbox/fcp/fcp2_0_client.py 2008-02-09 09:36:15 UTC (rev 197)
+++ trunk/sandbox/fcp/fcp2_0_client.py 2008-02-09 18:03:38 UTC (rev 198)
@@ -132,7 +132,14 @@
#FIX: we handle collisions in the client as savely as possible. But no guarantee either when a colliding file
# (...) finds his way into the download directory while downloading another.
#------------------------------------------------------------------------------------------------------------------------------------------------
-
+# [0002083: RemovePersistentRequest ignores unknown requests]
+#
+# minor one, but related to it a major one: you can not change the Priority of requests with
+# Persistence=conncetion
+#
+#FIX: workaround for the "related" part
+#------------------------------------------------------------------------------------------------------------------------------------------------
+
import atexit
import copy
import cPickle
@@ -1855,11 +1862,33 @@
@note: you can use this method to modify get / put related requests
All attempts to modify other requests will fail
@note: a RequestModified event is triggered as soon as the request has actually been modified
+ @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 simply not implemented in the client protocol.
+
"""
initialRequest = self._requests[requestIdentifier]
if not initialRequest['FcRequestType'] & (consts.RequestType.MaskGet | consts.RequestType.MaskPut):
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
+ 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')
+
+ if persistentUserData is not None:
+ initialRequest['FcPersistentUserData'] = persistentUserData
+ initialRequest['ClientToken'] = self.FcParams.messageToParams(initialRequest)
+ modified[consts.RequestModified.PersistentUserData] = None
+
+ initialRequest['FcModified'] = modified
+ self.events.RequestModified(initialRequest)
+ return
+
+
msg = self.Message(
consts.Message.ModifyPersistentRequest,
Identifier=initialRequest['Identifier'],
@@ -2158,18 +2187,31 @@
#testGetData()
def testGetFile():
+
+ def cb(event, request):
+ c.sendMessage(
+ #c.consts.Message.RemovePersistentRequest,
+ c.consts.Message.ModifyPersistentRequest,
+ Identifier=request['Identifier'],
+ PriorityClass=0,
+ Global=False,
+ )
+ pass
+
filename = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'test.jpg')
print filename
identifier = c.getFile(
'CHK@q4~2soHTd9SOINIoXmg~dn7LNUAOYzN1tHNHT3j4c9E,gcVRtoglEhgqN-DJolXPqJ4yX1f~1gBGh89HNWlFMWQ,AAIC--8/snow_002%20%2810%29.jpg',
filename,
filenameCollision=consts.FilenameCollision.HandleRename,
- #persistence=consts.Persistence.Forever,
+ #persistence=consts.Persistence.Reboot,
)
- c.run()
- #for i in xrange(50):
- # c.next()
+ c.events.RequestProgress += cb
+
+ #c.run()
+ for i in xrange(50):
+ c.next()
#c.removeRequest(identifier)
#for i in xrange(5):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|