From: <jU...@us...> - 2008-07-01 06:48:54
|
Revision: 445 http://fclient.svn.sourceforge.net/fclient/?rev=445&view=rev Author: jUrner Date: 2008-06-30 23:48:53 -0700 (Mon, 30 Jun 2008) Log Message: ----------- beautify Modified Paths: -------------- trunk/fcp2/src/fcp2/client.py Modified: trunk/fcp2/src/fcp2/client.py =================================================================== --- trunk/fcp2/src/fcp2/client.py 2008-06-30 12:15:39 UTC (rev 444) +++ trunk/fcp2/src/fcp2/client.py 2008-07-01 06:48:53 UTC (rev 445) @@ -886,13 +886,13 @@ return True requestType = msg['RequestType'] - if requestType & consts.RequestType.MaskGet: + if msg == message.PersistentGet: initialRequest = message.ClientGet() - elif requestType & (onsts.RequestType.PutDir | consts.RequestType.PutMultiple): - #NOTE: PutDiskDir is just a subtype of PutComplexDir + elif msg == message.PersistentPut: + initialRequest = message.ClientPut() + else: + #NOTE: PutDiskDir is just a subtype of PutComplexDir. check PutDirType param to tell appart initialRequest = message.ClientPutComplexDir() - else: - initialRequest = message.ClientPut() initialRequest.params.update(msg.params) self._requests[initialRequest['Identifier']] = initialRequest @@ -904,7 +904,7 @@ self.events.RequestRestored(initialRequest) return True - # known request ..don't handle it + # ignore return False This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-01 07:22:12
|
Revision: 449 http://fclient.svn.sourceforge.net/fclient/?rev=449&view=rev Author: jUrner Date: 2008-07-01 00:22:08 -0700 (Tue, 01 Jul 2008) Log Message: ----------- typos Modified Paths: -------------- trunk/fcp2/src/fcp2/client.py Modified: trunk/fcp2/src/fcp2/client.py =================================================================== --- trunk/fcp2/src/fcp2/client.py 2008-07-01 07:21:36 UTC (rev 448) +++ trunk/fcp2/src/fcp2/client.py 2008-07-01 07:22:08 UTC (rev 449) @@ -1482,7 +1482,7 @@ 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 uri: (L{key.USK}) key to subscribe to @param dontPoll: if True, does whatever ??? @return: (str) identifer of the request @@ -1827,7 +1827,7 @@ @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{chkPutDir} + @note: for other params see L{putDir} @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} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-01 08:03:45
|
Revision: 451 http://fclient.svn.sourceforge.net/fclient/?rev=451&view=rev Author: jUrner Date: 2008-07-01 01:03:55 -0700 (Tue, 01 Jul 2008) Log Message: ----------- added hack to handle persistents from other clients (kill them with fire ;-) Modified Paths: -------------- trunk/fcp2/src/fcp2/client.py Modified: trunk/fcp2/src/fcp2/client.py =================================================================== --- trunk/fcp2/src/fcp2/client.py 2008-07-01 08:03:27 UTC (rev 450) +++ trunk/fcp2/src/fcp2/client.py 2008-07-01 08:03:55 UTC (rev 451) @@ -142,7 +142,7 @@ # # suggested dropping of global persistents. pretty dangerous and unhandy imo. # -# +#FIX: at least some are implemented in the client #-------------------------------------------------------------------------------------------------------------------------------------------------- @@ -878,7 +878,7 @@ if initialRequest is None: if CancelPersistentRequests: self.sendMessage( - message.RemovePersistentRequest( + message.RemoveRequest( Identifier=msg['Identifier'], Global=msg['Global'], ) @@ -1120,8 +1120,18 @@ @note: use this method to run the client step by step. If you want to run the client unconditionally use L{run} """ + + #FIX: [0002083] we may run into persistents of other clients by accident. the client can not handle them. + # so remove them, no matter what.... + def hackyInvalidMessageCallback(msg, requests=self._requests): + if msg == message.PersistentGet or msg == message.PersistentPut or msg == message.PersistentPutDir: + requestIdentifier = msg['Identifier'] + if requestIdentifier not in requests: + msgRemove = message.RemoveRequest(Identifier=msg['Identifier'], Global=msg['Global']) + self.sendMessage(msgRemove) + try: - msg = self.ioHandler.readMessage() + msg = self.ioHandler.readMessage(hackyInvalidMessageCallback=hackyInvalidMessageCallback) except consts.IOTimeoutError, details: msg = message.ClientSocketTimeout() if dispatch: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-01 08:17:08
|
Revision: 453 http://fclient.svn.sourceforge.net/fclient/?rev=453&view=rev Author: jUrner Date: 2008-07-01 01:17:17 -0700 (Tue, 01 Jul 2008) Log Message: ----------- some notes Modified Paths: -------------- trunk/fcp2/src/fcp2/client.py Modified: trunk/fcp2/src/fcp2/client.py =================================================================== --- trunk/fcp2/src/fcp2/client.py 2008-07-01 08:04:06 UTC (rev 452) +++ trunk/fcp2/src/fcp2/client.py 2008-07-01 08:17:17 UTC (rev 453) @@ -184,11 +184,14 @@ # TODO: check if this is a bug in Fcp # NOTE: seems to be fixed in [build 1112], fixes removed #------------------------------------------------------------------------------------------------------------------------------------------------- -# PersistentPutDiskDir vs PutComplexDir + + +# reminders to self +#------------------------------------------------------------------------------------------------------------------------------------------------ +# Key() # -# x. currently not handled on PersistentPutDir. have to test this -# Fcp provides a new field "PutDirType": "complex" or "disk" to distinguish PutComplexDir and PutDiskDir -# +# we do not allow passing strings as uris. putting a CHK gets in the way here. would have to add another +# special case to handle 'CHK@myfilename' on input. so for uniformity reasons keys are enforced. #------------------------------------------------------------------------------------------------------------------------------------------------ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-01 11:26:39
|
Revision: 455 http://fclient.svn.sourceforge.net/fclient/?rev=455&view=rev Author: jUrner Date: 2008-07-01 04:26:47 -0700 (Tue, 01 Jul 2008) Log Message: ----------- for ease of use, all necessary symbols are now imported to main Modified Paths: -------------- trunk/fcp2/src/fcp2/client.py Modified: trunk/fcp2/src/fcp2/client.py =================================================================== --- trunk/fcp2/src/fcp2/client.py 2008-07-01 11:26:28 UTC (rev 454) +++ trunk/fcp2/src/fcp2/client.py 2008-07-01 11:26:47 UTC (rev 455) @@ -226,8 +226,10 @@ from fcp2.fcp_lib import uuid -del hack +del hack, _RelImportHack #<-- rel import hack + +__all__ = ['Client', ] #************************************************************************************************* # #************************************************************************************************* @@ -257,11 +259,11 @@ MaxSizeKeyInfo = 32768 MinimumRunTime = 1 # FIX: 0001931 - consts = consts - config = config - message = message - types = types - key = key + #consts = consts + #config = config + #message = message + #types = types + #key = key def __init__(self, @@ -270,7 +272,7 @@ ): """ @param connectionName: name of the connection or None to use an arbitrary connection name - @param debugVerbosity: verbosity level for debugging. Default is L{consts.DebugVerbosity.Warning} + @param debugVerbosity: verbosity level for debugging. Default is L{consts.ConstDebugVerbosity.Warning} """ self._connectionName = self.setConnectionName(connectionName) @@ -282,7 +284,7 @@ for event in self.events: event += self._captureEvent - self.setDebugVerbosity(consts.DebugVerbosity.Warning if debugVerbosity is None else debugVerbosity) + self.setDebugVerbosity(consts.ConstDebugVerbosity.Warning if debugVerbosity is None else debugVerbosity) atexit.register(self.close) ############################################################### @@ -292,9 +294,9 @@ ############################################################### def _captureEvent(self, event, request): if event == self.events.Idle: - consts.Logger.Event.log(consts.DebugVerbosity.Chatty, consts.LogMessages.EventTriggered + event.name) + consts.ConstLogger.Event.log(consts.ConstDebugVerbosity.Chatty, consts.ConstLogMessages.EventTriggered + event.name) else: - consts.Logger.Event.info(consts.LogMessages.EventTriggered + event.name) + consts.ConstLogger.Event.info(consts.ConstLogMessages.EventTriggered + event.name) def _close(self, msg): @@ -305,7 +307,7 @@ @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) + consts.ConstLogger.Client.info(consts.ConstLogMessages.Closing) # clean left over DDA test tmp files for initialRequest in self._ddaTests: @@ -328,21 +330,21 @@ @param request: request to finalize @param event: event to trigger or None - @note: this method sets the requests L{consts.RequestStatus.RemovedFromQueue} and - L{consts.RequestStatus.Completed} flags accordingly + @note: this method sets the requests L{consts.ConstRequestStatus.RemovedFromQueue} and + L{consts.ConstRequestStatus.Completed} flags accordingly @note: Fcp removes Get / Put requests with Persistence == connection emidiately from its queue. Same goes all requests on ProtocolError. We inform the caller that the request has been completed and remove it fom our queue if necessary. Non Get / Put requests will be removed in any case. """ - removeRequest = msg == message.ProtocolError or msg == message.PersistentRequestRemoved # TODO: PersistentRequestRemoved??? + removeRequest = msg == message.MsgProtocolError or msg == message.MsgPersistentRequestRemoved # TODO: PersistentRequestRemoved??? if not removeRequest: #NOTE: non Get / Put related requests do not have a Persistence param - removeRequest = request.params.get('Persistence', consts.Persistence.Connection) == consts.Persistence.Connection + removeRequest = request.params.get('Persistence', consts.ConstPersistence.Connection) == consts.ConstPersistence.Connection if removeRequest: - request['RequestStatus'] |= consts.RequestStatus.RemovedFromQueue + request['RequestStatus'] |= consts.ConstRequestStatus.RemovedFromQueue - request['RequestStatus'] |= consts.RequestStatus.Completed + request['RequestStatus'] |= consts.ConstRequestStatus.Completed if event is not None: event(request) @@ -370,13 +372,13 @@ identifier=None, initTime=None, persistentUserData='', - filenameCollision=consts.FilenameCollision.HandleNever, + filenameCollision=consts.ConstFilenameCollision.HandleNever, ): """Registers a request @param msg: message to register - @param requestType: (L{consts.RequestType}) type of request to register - @param filenameCollision: (L{consts.FilenameCollision}) how to handle filename collisions. - Default is L{consts.FilenameCollision.HandleNever} + @param requestType: (L{consts.ConstRequestType}) type of request to register + @param filenameCollision: (L{consts.ConstFilenameCollision}) how to handle filename collisions. + Default is L{consts.ConstFilenameCollision.HandleNever} @param identifier: (str) identifier of the request or None to create a new one @param initTime: (int) init time of the request or None to set it to now @param persistentUserData: (str) anyuser defined persistent data @@ -390,39 +392,27 @@ # equip requests with some additional params #TODO: keep an eye on additional params, they may collide with Fcp parameters - Private = message.PrivateParam - - """ - @requestparam: B{ErrorMessage:} (L{messageMessage}) if an error occured - @requestparam: B{Modified:} (dict) - @requestparam: B{Modified:} (dict) - @requestparam: B{PrivateKey:} None. Will contain the private key as soon as the key is generated - @requestparam: B{PublicKey:} None. Will contain the public key as soon as the key is generated - @requestparam: B{RequestStatus:} one or more of the L{consts.RequestStatus} flags - @requestparam: B{RequestType:} one or more of the L{consts.RequestType} flags - @requestparam: B{Identifier:} identifier of the request - """ msg['Identifier'] = self._newUuid(uuids=self._requests) if identifier is None else identifier msg['RequestType'] = requestType msg['InitTime'] = time.time() if initTime is None else initTime - if requestType & consts.RequestType.MaskGet: + if requestType & consts.ConstRequestType.MaskGet: msg['FilenameCollision'] = filenameCollision msg['UserData'] = userData msg['PersistentUserData'] = persistentUserData msg['ClientToken'] = '' msg.updatePersistentParams() - elif requestType & consts.RequestType.MaskPut: + elif requestType & consts.ConstRequestType.MaskPut: msg['UserData'] = userData msg['PersistentUserData'] = persistentUserData msg['ClientToken'] = '' msg.updatePersistentParams() - elif requestType & consts.RequestType.MaskGenerateKeypair: + elif requestType & consts.ConstRequestType.MaskGenerateKeypair: pass - elif requestType & consts.RequestType.SubscribeUSK: + elif requestType & consts.ConstRequestType.SubscribeUSK: msg['UserData'] = userData - elif requestType & consts.RequestType.PluginInfo: + elif requestType & consts.ConstRequestType.PluginInfo: pass else: raise ValueError('Can not register request: ' + msg.name) @@ -438,15 +428,15 @@ """Closes the client @note: make shure to call close() when done with the client """ - msg = message.ClientDisconnected( - DisconnectReason=consts.DisconnectReason.Close, + msg = message.MsgClientDisconnected( + DisconnectReason=consts.ConstDisconnectReason.Close, ) self._close(msg) def closeNode(self): """Shuts down the freenet node""" - self.sendMessage(message.Shutdown()) + self.sendMessage(message.MsgShutdown()) def connect(self, host=DefaultFcpHost, port=DefaultFcpPort, duration=20, timeout=0.5): @@ -456,7 +446,7 @@ @param duration: (int) how many seconds try to connect before giving up @param timeout: (int) how much time to wait before another attempt to connect - @return: (L{message.Message}) NodeHello or None if no connection could be established + @return: (L{message.MsgMessage}) NodeHello or None if no connection could be established """ nodeHello = None for nodeHello in self.iterConnect(host=host, port=port, duration=duration, timeout=timeout): @@ -479,7 +469,7 @@ @param duration: (int) how many seconds try to connect before giving up @param timeout: (int) how much time to wait before another attempt to connect - @return: (L{message.Message}) NodeHello if successful, None otherwise for the next iteration + @return: (L{message.MsgMessage}) NodeHello if successful, None otherwise for the next iteration @event: ClientConnected(event, message) is triggered as soon as the client is connected """ @@ -487,12 +477,12 @@ #TODO: we have to yield a few round here to make NodeHello injection work in unittests # no idea exactly how many... if self.ioHandler.isOpen(): - disconnectMsg = message.ClientDisconnected( - DisconnectReason=consts.DisconnectReason.Reconnect, + disconnectMsg = message.MsgClientDisconnected( + DisconnectReason=consts.ConstDisconnectReason.Reconnect, ) self._close(disconnectMsg) - disconnectReason = consts.DisconnectReason.IOConnectFailed + disconnectReason = consts.ConstDisconnectReason.IOConnectFailed t0 = time.time() for result in self.ioHandler.iterConnect(duration=duration, timeout=timeout, host=host, port=port): yield None @@ -501,7 +491,7 @@ timeElapsed = time.time() - t0 if result: self.sendMessage( - message.ClientHello( + message.MsgClientHello( Name=self._connectionName, ExpectedVersion=self.ExpectedFcpVersion, ) @@ -510,11 +500,11 @@ while timeElapsed <= duration: yield None msg = self.next(dispatch=False) - if msg == message.ClientSocketTimeout: - disconnectReason = consts.DisconnectReason.NoNodeHello + if msg == message.MsgClientSocketTimeout: + disconnectReason = consts.ConstDisconnectReason.NoNodeHello timeElapsed += max(self.ioHandler.io.Timeout, 0.1) yield None - elif msg == message.NodeHello: + elif msg == message.MsgNodeHello: self._nodeHelloMessage = msg # check if version is ok if self.versionCheckNodeHello(msg): @@ -522,13 +512,13 @@ yield self._nodeHelloMessage raise StopIteration else: - disconnectReason = consts.DisconnectReason.VersionMissmatch + disconnectReason = consts.ConstDisconnectReason.VersionMissmatch break else: - disconnectReason = consts.DisconnectReason.UnknownNodeHello + disconnectReason = consts.ConstDisconnectReason.UnknownNodeHello break - disconnectMsg = message.ClientDisconnected( + disconnectMsg = message.MsgClientDisconnected( DisconnectReason=disconnectReason, ) self._close(disconnectMsg) @@ -553,17 +543,17 @@ def getDebugVerbosity(self): """Returns the current verbosity level of the client - @return: L{consts.DebugVerbosity} + @return: L{consts.ConstDebugVerbosity} """ - return consts.Logger.Client.getEffectiveLevel() + return consts.ConstLogger.Client.getEffectiveLevel() def setDebugVerbosity(self, debugVerbosity): """Sets the verbosity level of the client - @param debugVerbosity: L{consts.DebugVerbosity} + @param debugVerbosity: L{consts.ConstDebugVerbosity} """ - consts.Logger.Client.setLevel(debugVerbosity) + consts.ConstLogger.Client.setLevel(debugVerbosity) @@ -616,7 +606,7 @@ ## errors ## #################################################### - if msg == message.IdentifierCollision: + if msg == message.MsgIdentifierCollision: if initialRequest is None: self.events.IdentifierCollision(msg) return False @@ -626,17 +616,17 @@ self._requests[newIdentifier] = initialRequest del self._requests[requestIdentifier] initialRequest['Identifier'] = newIdentifier - initialRequest['Modified'] = {consts.RequestModified.Identifier: requestIdentifier} + initialRequest['Modified'] = {consts.ConstRequestModified.Identifier: requestIdentifier} self.events.RequestModified(initialRequest) self.sendMessage(initialRequest) return True - elif msg == message.ProtocolError: + elif msg == message.MsgProtocolError: code = msg['Code'] - if code == consts.ProtocolError.ShuttingDown: - disconnectMsg = message.ClientDisconnected( - DisconnectReason=consts.DisconnectReason.NodeClosing, + if code == consts.ConstProtocolError.ShuttingDown: + disconnectMsg = message.MsgClientDisconnected( + DisconnectReason=consts.ConstDisconnectReason.NodeClosing, ) self._close(disconnectMsg) return True @@ -651,9 +641,9 @@ return False # handle DDA errors - elif code == consts.ProtocolError.DDADenied: - ddaRequestMsg = message.TestDDARequest() - if initialRequest == message.ClientGet: + elif code == consts.ConstProtocolError.DDADenied: + ddaRequestMsg = message.MsgTestDDARequest() + if initialRequest == message.MsgClientGet: ddaRequestMsg['WantWriteDirectory'] = True directory = os.path.dirname(initialRequest['Filename']) else: @@ -675,31 +665,31 @@ # handle filename collisions - elif code == consts.ProtocolError.DiskTargetExists: - handleCollision = initialRequest.get('FilenameCollision', consts.FilenameCollision.HandleNever) - collisionHandled = bool(handleCollision & consts.FilenameCollision.CollisionHandled) + elif code == consts.ConstProtocolError.DiskTargetExists: + handleCollision = initialRequest.get('FilenameCollision', consts.ConstFilenameCollision.HandleNever) + collisionHandled = bool(handleCollision & consts.ConstFilenameCollision.CollisionHandled) # rename filename - if handleCollision & consts.FilenameCollision.HandleRename: + if handleCollision & consts.ConstFilenameCollision.HandleRename: filename = initialRequest['Filename'] - initialRequest['FilenameCollision'] |= consts.FilenameCollision.CollisionHandled + initialRequest['FilenameCollision'] |= consts.ConstFilenameCollision.CollisionHandled newFilename = namespace.unique_filename(filename, extensions=1, ispostfixed=collisionHandled) initialRequest['Filename'] = newFilename - initialRequest['Modified'] = {consts.RequestModified.Filename: filename} + initialRequest['Modified'] = {consts.ConstRequestModified.Filename: filename} self.sendMessage(initialRequest) self.events.RequestModified(initialRequest) return True # don't handle else: - initialRequest['FilenameCollision'] &= ~consts.FilenameCollision.CollisionHandled + initialRequest['FilenameCollision'] &= ~consts.ConstFilenameCollision.CollisionHandled # handle plugin related request failures - elif code == consts.ProtocolError.NoSuchPlugin or code == consts.ProtocolError.AccessDenied: - if initialRequest == message.GetPluginInfo: + elif code == consts.ConstProtocolError.NoSuchPlugin or code == consts.ConstProtocolError.AccessDenied: + if initialRequest == message.MsgGetPluginInfo: initialRequest['ErrorMessage'] = msg - initialRequest['RequestStatus'] |= consts.RequestStatus.Error + initialRequest['RequestStatus'] |= consts.ConstRequestStatus.Error self._finalizeRequest(msg, initialRequest, self.events.PluginInfoFailed) return True @@ -707,7 +697,7 @@ # NOTE: Fcp already removed the request initialRequest['ErrorMessage'] = msg - initialRequest['RequestStatus'] |= consts.RequestStatus.Error + initialRequest['RequestStatus'] |= consts.ConstRequestStatus.Error self._finalizeRequest(msg, initialRequest, self.events.RequestFailed) return True @@ -721,7 +711,7 @@ ## TestDDA drill. ## #################################################### - elif msg == message.TestDDAReply: + elif msg == message.MsgTestDDAReply: directory = msg['Directory'] # find message that triggered the call @@ -752,7 +742,7 @@ initialRequest['TestDDA']['TmpFile'] = fpathWrite self.sendMessage( - message.TestDDAResponse( + message.MsgTestDDAResponse( Directory=msg['Directory'], ReadContent=readContent, ) @@ -760,7 +750,7 @@ return True - elif msg == message.TestDDAComplete: + elif msg == message.MsgTestDDAComplete: # clean up tmp file directory = msg['Directory'] @@ -787,7 +777,7 @@ testFailed = not msg.params.get('ReadDirectoryAllowed', False) if testFailed: - initialRequest['RequestStatus'] = consts.RequestStatus.Error + initialRequest['RequestStatus'] = consts.ConstRequestStatus.Error initialRequest['ErrorMessage'] = initialRequest['TestDDA']['ErrorMsg'] self._finalizeRequest(msg, initialRequest, self.events.RequestFailed) return True @@ -801,11 +791,11 @@ ## config related ## #################################################### - elif msg == message.ConfigData: + elif msg == message.MsgConfigData: self.events.ConfigData(msg) return True - elif msg == message.NodeData: + elif msg == message.MsgNodeData: self.events.NodeData(msg) return True @@ -814,20 +804,20 @@ ## get / put related ## #################################################### - elif msg == message.AllData: + elif msg == message.MsgAllData: if initialRequest is None: return False - initialRequest['RequestStatus'] |= consts.RequestStatus.Success + initialRequest['RequestStatus'] |= consts.ConstRequestStatus.Success initialRequest.data = msg.data self._finalizeRequest(msg, initialRequest, self.events.RequestCompleted) return True - elif msg == message.DataFound: + elif msg == message.MsgDataFound: if initialRequest is None: return False - initialRequest['RequestStatus'] |= consts.RequestStatus.Success + initialRequest['RequestStatus'] |= consts.ConstRequestStatus.Success initialRequest['MetadataContentType'] = msg.get('Metadata.ContentType', '') initialRequest['MetadataSize'] = msg.get('DataLength', '') @@ -836,10 +826,10 @@ # For GetData with persistence != connection the node sends no All Data message # whatever that is good for ..fix this here to get all GetData request to complete on # All Data. - if initialRequest['RequestType'] == consts.RequestType.GetData: - if initialRequest['Persistence'] != consts.Persistence.Connection: + if initialRequest['RequestType'] == consts.ConstRequestType.GetData: + if initialRequest['Persistence'] != consts.ConstPersistence.Connection: self.sendMessage( - message.GetRequestStatus( + message.MsgGetRequestStatus( Identifier=initialRequest['Identifier'], Global=False, OnlyData=True @@ -851,37 +841,37 @@ return True - elif msg == message.GetFailed: + elif msg == message.MsgGetFailed: if initialRequest is None: return False code = msg['Code'] - if code == consts.FetchError.Canceled: - initialRequest['RequestStatus'] |= consts.RequestStatus.Removed | consts.RequestStatus.Completed | consts.RequestStatus.RemovedFromQueue + if code == consts.ConstFetchError.Canceled: + initialRequest['RequestStatus'] |= consts.ConstRequestStatus.Removed | consts.ConstRequestStatus.Completed | consts.ConstRequestStatus.RemovedFromQueue del self._requests[requestIdentifier] self.events.RequestRemoved(initialRequest) return True # check if it is one of our requests for key information - if code == consts.FetchError.TooBig and initialRequest['RequestType'] == consts.RequestType.GetKeyInfo: + if code == consts.ConstFetchError.TooBig and initialRequest['RequestType'] == consts.ConstRequestType.GetKeyInfo: initialRequest['MetadataContentType'] = msg.get('ExpectedMetadata.ContentType', '') initialRequest['DataLength'] = msg.get('ExpectedDataLength', -1) - initialRequest['RequestStatus'] |= consts.RequestStatus.Success + initialRequest['RequestStatus'] |= consts.ConstRequestStatus.Success self._finalizeRequest(msg, initialRequest, self.events.RequestCompleted) else: initialRequest['ErrorMessage'] = msg - initialRequest['RequestStatus'] |= consts.RequestStatus.Error + initialRequest['RequestStatus'] |= consts.ConstRequestStatus.Error self._finalizeRequest(msg, initialRequest, self.events.RequestFailed) return True - elif msg == message.PersistentGet or msg == message.PersistentPut or msg == message.PersistentPutDir: + elif msg == message.MsgPersistentGet or msg == message.MsgPersistentPut or msg == message.MsgPersistentPutDir: # unknown request... try to restore it if initialRequest is None: if CancelPersistentRequests: self.sendMessage( - message.RemoveRequest( + message.MsgRemoveRequest( Identifier=msg['Identifier'], Global=msg['Global'], ) @@ -889,13 +879,13 @@ return True requestType = msg['RequestType'] - if msg == message.PersistentGet: - initialRequest = message.ClientGet() - elif msg == message.PersistentPut: - initialRequest = message.ClientPut() + if msg == message.MsgPersistentGet: + initialRequest = message.MsgClientGet() + elif msg == message.MsgPersistentPut: + initialRequest = message.MsgClientPut() else: #NOTE: PutDiskDir is just a subtype of PutComplexDir. check PutDirType param to tell appart - initialRequest = message.ClientPutComplexDir() + initialRequest = message.MsgClientPutComplexDir() initialRequest.params.update(msg.params) self._requests[initialRequest['Identifier']] = initialRequest @@ -903,7 +893,7 @@ #FIX: remove Started param from PersistentGet / Put, not interesting if 'Started' in initialRequest.params: del initialRequest.params['Started'] - initialRequest['RequestStatus'] |= consts.RequestStatus.Restored + initialRequest['RequestStatus'] |= consts.ConstRequestStatus.Restored self.events.RequestRestored(initialRequest) return True @@ -911,7 +901,7 @@ return False - elif msg == message.PersistentRequestModified: + elif msg == message.MsgPersistentRequestModified: if initialRequest is None: return False @@ -920,7 +910,7 @@ # check if PersistentUserData has changed clientToken = msg.get('ClientToken', None) if clientToken is not None: - modified[consts.RequestModified.PersistentUserData] = None + modified[consts.ConstRequestModified.PersistentUserData] = None #TODO: its more or less a guess that PersistentUserData has changed # ...as long as no other param is changed at runtime we are ok @@ -937,7 +927,7 @@ # check if PriorityClass has changed priorityClass = msg.get('PriorityClass', None) if priorityClass is not None: - modified[consts.RequestModified.PriorityClass] = None + modified[consts.ConstRequestModified.PriorityClass] = None initialRequest['PriorityClass'] = priorityClass initialRequest['Modified'] = modified @@ -945,16 +935,16 @@ return True #NOTE: fcp sends a GetFailed / PutFailed if the request was still running (code=canceled) - elif msg == message.PersistentRequestRemoved: + elif msg == message.MsgPersistentRequestRemoved: if initialRequest is None: return False - initialRequest['RequestStatus'] |= consts.RequestStatus.Removed | consts.RequestStatus.Completed | consts.RequestStatus.RemovedFromQueue + initialRequest['RequestStatus'] |= consts.ConstRequestStatus.Removed | consts.ConstRequestStatus.Completed | consts.ConstRequestStatus.RemovedFromQueue del self._requests[requestIdentifier] self.events.RequestRemoved(initialRequest) return True - elif msg == message.SimpleProgress: + elif msg == message.MsgSimpleProgress: if initialRequest is None: return False @@ -968,24 +958,24 @@ ## put related - elif msg == message.PutFailed: + elif msg == message.MsgPutFailed: if initialRequest is None: return False code = msg['Code'] - if code == consts.InsertError.Canceled: - initialRequest['RequestStatus'] |= consts.RequestStatus.Removed | consts.RequestStatus.Completed | consts.RequestStatus.RemovedFromQueue + if code == consts.ConstInsertError.Canceled: + initialRequest['RequestStatus'] |= consts.ConstRequestStatus.Removed | consts.ConstRequestStatus.Completed | consts.ConstRequestStatus.RemovedFromQueue del self._requests[requestIdentifier] self.events.RequestRemoved(initialRequest) return True - initialRequest['RequestStatus'] |= consts.RequestStatus.Error + initialRequest['RequestStatus'] |= consts.ConstRequestStatus.Error initialRequest['ErrorMessage'] = msg self._finalizeRequest(msg, initialRequest, self.events.RequestFailed) return True - elif msg == message.PutFetchable: + elif msg == message.MsgPutFetchable: if initialRequest is None: # something went wrong return False @@ -994,35 +984,35 @@ return True - elif msg == message.PutSuccessful: + elif msg == message.MsgPutSuccessful: if initialRequest is None: return False # TODO: StartupTime and CompletionTime are passed, but # as long as no corrosponding params are passed in DataFound # we ignore them - initialRequest['RequestStatus'] |= consts.RequestStatus.Success + initialRequest['RequestStatus'] |= consts.ConstRequestStatus.Success initialRequest['URI'] = msg['URI'] self._finalizeRequest(msg, initialRequest, self.events.RequestCompleted) return True - elif msg == message.URIGenerated: + elif msg == message.MsgURIGenerated: if initialRequest is None: return False initialRequest['URI'] = msg['URI'] return True - elif msg == message.FinishedCompression: + elif msg == message.MsgFinishedCompression: if initialRequest is None: return False - initialRequest['RequestStatus'] |= consts.RequestStatus.Compressed + initialRequest['RequestStatus'] |= consts.ConstRequestStatus.Compressed self.events.RequestCompressionCompleted(initialRequest) return True - elif msg == message.StartedCompression: + elif msg == message.MsgStartedCompression: if initialRequest is None: return False - initialRequest['RequestStatus'] |= consts.RequestStatus.Compressing + initialRequest['RequestStatus'] |= consts.ConstRequestStatus.Compressing self.events.RequestCompressionStarted(initialRequest) return True @@ -1031,31 +1021,31 @@ ## Peer related messages ## #################################################### - elif msg == message.EndListPeers: + elif msg == message.MsgEndListPeers: self.events.EndListPeers(msg) return True - elif msg == message.EndListPeerNotes: + elif msg == message.MsgEndListPeerNotes: self.events.EndListPeerNotes(msg.params) return True - elif msg == message.Peer: + elif msg == message.MsgPeer: self.events.Peer(msg) return True - elif msg == message.PeerNote: + elif msg == message.MsgPeerNote: self.events.PeerNote(msg) return True - elif msg == message.PeerRemoved: + elif msg == message.MsgPeerRemoved: self.events.PeerRemoved(msg) return True - elif msg == message.UnknownNodeIdentifier: + elif msg == message.MsgUnknownNodeIdentifier: self.events.PeerUnknown(msg) return True - elif msg == message.UnknownPeerNoteType: + elif msg == message.MsgUnknownPeerNoteType: self.events.PeerNoteTypeUnknown(msg) return True #################################################### @@ -1063,15 +1053,15 @@ ## plugins ## #################################################### - elif msg == message.PluginInfo: + elif msg == message.MsgPluginInfo: if initialRequest is None: return False - initialRequest['RequestStatus'] |= consts.RequestStatus.Success + initialRequest['RequestStatus'] |= consts.ConstRequestStatus.Success self._finalizeRequest(msg, initialRequest, self.events.PluginInfo) return True - elif msg == message.FCPPluginReply: + elif msg == message.MsgFCPPluginReply: self.events.PluginMessage(msg) return True @@ -1080,31 +1070,31 @@ ## others ## #################################################### - elif msg == message.CloseConnectionDuplicateClientName: - disconnectMsg = message.ClientDisconnected( - DisconnectReason=consts.DisconnectReason.DuplicateClientName, + elif msg == message.MsgCloseConnectionDuplicateClientName: + disconnectMsg = message.MsgClientDisconnected( + DisconnectReason=consts.ConstDisconnectReason.DuplicateClientName, ) self._close(disconnectMsg) return True - elif msg == message.SSKKeypair: + elif msg == message.MsgSSKKeypair: if initialRequest is None: return False 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) + if initialRequest['RequestType'] == consts.ConstRequestType.GenerateUSKKeypair: + insertURI = key.KeyUSK(insertURI.keyData, filename=insertURI.filename) + requestURI = key.KeyUSK(requestURI.keyData, filename=requestURI.filename) initialRequest['InsertURI'] = insertURI initialRequest['RequestURI'] = requestURI - initialRequest['RequestStatus'] |= consts.RequestStatus.Success + initialRequest['RequestStatus'] |= consts.ConstRequestStatus.Success self._finalizeRequest(msg, initialRequest, self.events.KeypairGenerated) return True - elif msg == message.SubscribedUSKUpdate: + elif msg == message.MsgSubscribedUSKUpdate: if initialRequest is None: return False @@ -1127,24 +1117,24 @@ #FIX: [0002083] we may run into persistents of other clients by accident. the client can not handle them. # so remove them, no matter what.... def hackyInvalidMessageCallback(msg, requests=self._requests): - if msg == message.PersistentGet or msg == message.PersistentPut or msg == message.PersistentPutDir: + if msg == message.MsgPersistentGet or msg == message.MsgPersistentPut or msg == message.MsgPersistentPutDir: requestIdentifier = msg['Identifier'] if requestIdentifier not in requests: - msgRemove = message.RemoveRequest(Identifier=msg['Identifier'], Global=msg['Global']) + msgRemove = message.MsgRemoveRequest(Identifier=msg['Identifier'], Global=msg['Global']) self.sendMessage(msgRemove) try: msg = self.ioHandler.readMessage(hackyInvalidMessageCallback=hackyInvalidMessageCallback) - except consts.IOTimeoutError, details: - msg = message.ClientSocketTimeout() + except consts.ErrorIOTimeout, details: + msg = message.MsgClientSocketTimeout() if dispatch: self.events.Idle(msg) - except consts.IOBrokenError, details: - msg = message.ClientDisconnected( - DisconnectReason=consts.DisconnectReason.ConnectionDied, + except consts.ErrorIOBroken, details: + msg = message.MsgClientDisconnected( + DisconnectReason=consts.ConstDisconnectReason.ConnectionDied, ) self._close(msg) - raise consts.IOBrokenError(details) + raise consts.ErrorIOBroken(details) else: if dispatch: self.handleMessage(msg) @@ -1163,9 +1153,9 @@ try: msg = self.next() except KeyboardInterrupt: - consts.Logger.Client.info(consts.LogMessages.KeyboardInterrupt) + consts.ConstLogger.Client.info(consts.ConstLogMessages.KeyboardInterrupt) return - if msg == message.ClientSocketDied: + if msg == message.MsgClientSocketDied: return #n = 0 @@ -1176,28 +1166,28 @@ # check if we have running requests. Assert False haveRunningRequests = False for request in self._requests.values(): - if not request['RequestStatus'] & consts.RequestStatus.Completed: + if not request['RequestStatus'] & consts.ConstRequestStatus.Completed: haveRunningRequests = True break if not haveRunningRequests: - consts.Logger.Client.info(consts.LogMessages.AllRequestsCompleted) + consts.ConstLogger.Client.info(consts.ConstLogMessages.AllRequestsCompleted) break try: msg = self.next() except KeyboardInterrupt: - sconsts.Logger.Client.info(consts.LogMessages.KeyboardInterrupt) + sconsts.ConstLogger.Client.info(consts.ConstLogMessages.KeyboardInterrupt) break - if msg == message.ClientSocketDied: + if msg == message.MsgClientSocketDied: break def sendMessage(self, msg): """Sends a message to freenet - @param msg: (L{message.Message}) message to send - @return: (L{message.Message}) disconnect if something went wrong + @param msg: (L{message.MsgMessage}) message to send + @return: (L{message.MsgMessage}) disconnect if something went wrong @note: If an error occurs the client is closed @note: you can use this method to send a message to the node, bypassing all @@ -1210,12 +1200,12 @@ # ...so assume data was send, cos there is no way to proove it was not send try: self.ioHandler.sendMessage(msg) - except consts.IOBrokenError, details: - errorMsg = message.ClientDisconnected( - DisconnectReason=consts.DisconnectReason.ConnectionDied, + except consts.ErrorIOBroken, details: + errorMsg = message.MsgClientDisconnected( + DisconnectReason=consts.ConstDisconnectReason.ConnectionDied, ) self._close(errorMsg) - raise consts.IOBrokenError(details) + raise consts.ErrorIOBroken(details) ######################################################### ## @@ -1236,7 +1226,7 @@ @event: ConfigData(event, msg) """ self.sendMessage( - message.GetConfig( + message.MsgGetConfig( WithSortOrder=withSortOrder, WithCurrent=withCurrent, WithDefaults=withDefaults, @@ -1254,7 +1244,7 @@ """Modifies node configuration values @param params: (dict) containing parameters to modify """ - msg = message.ModifyConfig() + msg = message.MsgModifyConfig() msg.params = params self.sendMessage(msg) @@ -1273,7 +1263,7 @@ ): """Requests a key from the node @param uri: (L{key.KeyBase}) key to request - @param requestType: (L{consts.RequestType}) sub type of the message + @param requestType: (L{consts.ConstRequestType}) 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 @param filenameCollision: what to do if the disk target alreaady exists. One of the FilenameCollision.* consts @@ -1282,7 +1272,7 @@ @return: (str) request identifier """ - msg = message.ClientGet(URI=uri) + msg = message.MsgClientGet(URI=uri) for paramName, value in messageParams.items(): if value is not None: msg[paramName] = value @@ -1308,8 +1298,8 @@ ignoreDS=False, maxRetries=None, maxSize=None, - persistence=consts.Persistence.Connection, - priorityClass=consts.Priority.Medium, + persistence=consts.ConstPersistence.Connection, + priorityClass=consts.ConstPriority.Medium, userData=None, persistentUserData='', @@ -1324,8 +1314,8 @@ @param ignoreDS: (bool) if True, ignores the local data store @param maxRetries: (int) maximum number of retries or -1 to retry forver or None to leave it to the node to decide @param maxSize: (int) maximum size of the file in bytes or None to set no limited - @param persistence: (L{consts.Persistence}) persistence of the request - @param priorityClass: (L{consts.Priority}) priority of the request + @param persistence: (L{consts.ConstPersistence}) persistence of the request + @param priorityClass: (L{consts.ConstPriority}) 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 @@ -1338,15 +1328,15 @@ @note: the identifier of the request may change at any time. You should be prepaired to handle this - @note: if persistence is L{consts.Persistence.Connection} the request is removed from the client + @note: if persistence is L{consts.ConstPersistence.Connection} the request is removed from the client as soon as it completes or failes """ return self.clientGet( uri, - consts.RequestType.GetData, + consts.ConstRequestType.GetData, userData, persistentUserData, - consts.FilenameCollision.HandleNever, + consts.ConstFilenameCollision.HandleNever, # Fcp params AllowedMimeTypes = allowedMimeTypes, @@ -1359,8 +1349,8 @@ MaxSize = maxSize, Persistence=persistence, PriorityClass=priorityClass, - ReturnType=consts.ReturnType.Direct, - Verbosity=consts.Verbosity.ReportProgress, + ReturnType=consts.ConstReturnType.Direct, + Verbosity=consts.ConstVerbosity.ReportProgress, ) @@ -1375,12 +1365,12 @@ ignoreDS=False, maxRetries=None, maxSize=None, - persistence=consts.Persistence.Connection, - priorityClass=consts.Priority.Medium, + persistence=consts.ConstPersistence.Connection, + priorityClass=consts.ConstPriority.Medium, userData=None, persistentUserData='', - filenameCollision=consts.FilenameCollision.HandleNever, + filenameCollision=consts.ConstFilenameCollision.HandleNever, ): """Requests a file from the node @@ -1393,8 +1383,8 @@ @param ignoreDS: If True, ignores the local data store @param maxRetries: (int) maximum number of retries or -1 to retry forver or None to leave it to the node to decide @param maxSize: (int) maximum size of the file in bytes or None to set no limited - @param persistence: (L{consts.Persistence}) persistence of the request - @param priorityClass: (L{consts.Priority}) priority of the request + @param persistence: (L{consts.ConstPersistence}) persistence of the request + @param priorityClass: (L{consts.ConstPriority}) priority of the request @param filenameCollision: what to do if the disk target alreaady exists. One of the FilenameCollision.* consts @param userData: any non persistent data to associate to the request @param persistentUserData: any string to associate to the request as persistent data @@ -1407,12 +1397,12 @@ filename changes or the request is modified otherwise (see L{modifyRequest}) - @note: if persistence is L{consts.Persistence.Connection} the request is removed from the client + @note: if persistence is L{consts.ConstPersistence.Connection} the request is removed from the client as soon as it completes or failes """ return self.clientGet( uri, - consts.RequestType.GetFile, + consts.ConstRequestType.GetFile, userData, persistentUserData, filenameCollision, @@ -1429,8 +1419,8 @@ MaxSize = maxSize, Persistence=persistence, PriorityClass=priorityClass, - ReturnType=consts.ReturnType.Disk, - Verbosity=consts.Verbosity.ReportProgress, + ReturnType=consts.ConstReturnType.Disk, + Verbosity=consts.ConstVerbosity.ReportProgress, ) @@ -1441,8 +1431,8 @@ dsOnly=False, ignoreDS=False, maxRetries=None, - persistence=consts.Persistence.Connection, - priorityClass=consts.Priority.Medium, + persistence=consts.ConstPersistence.Connection, + priorityClass=consts.ConstPriority.Medium, userData=None, persistentUserData='', @@ -1454,8 +1444,8 @@ @param dsOnly: if True, retrieves the file from the local data store only @param ignoreDS: If True, ignores the local data store @param maxRetries: (int) maximum number of retries or -1 to retry forver or None to leave it to the node to decide - @param persistence: (L{consts.Persistence}) persistence of the request - @param priorityClass: (L{consts.Priority}) priority of the request + @param persistence: (L{consts.ConstPersistence}) persistence of the request + @param priorityClass: (L{consts.ConstPriority}) 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 @@ -1467,16 +1457,16 @@ @event: RequestModified(event, message) trigggered if the request identifier changes or the request is modified otherwise (see L{modifyRequest}) - @note: if persistence is L{consts.Persistence.Connection} the request is removed from the client + @note: if persistence is L{consts.ConstPersistence.Connection} the request is removed from the client as soon as it completes or failes """ # how to retrieve meta info about a key? ...idea is to provoke a GetFailed (TooBig) return self.clientGet( uri, - consts.RequestType.GetKeyInfo, + consts.ConstRequestType.GetKeyInfo, userData, persistentUserData, - consts.FilenameCollision.HandleNever, + consts.ConstFilenameCollision.HandleNever, # Fcp params Global=False, @@ -1487,8 +1477,8 @@ MaxSize=self.MaxSizeKeyInfo, Persistence=persistence, PriorityClass=priorityClass, - ReturnType=consts.ReturnType.Nothing, - Verbosity=consts.Verbosity.ReportProgress, + ReturnType=consts.ConstReturnType.Nothing, + Verbosity=consts.ConstVerbosity.ReportProgress, ) @@ -1499,17 +1489,17 @@ @param dontPoll: if True, does whatever ??? @return: (str) identifer of the request - @note: this request can not be removed or modified so the L{consts.RequestStatus.Completed} + @note: this request can not be removed or modified so the L{consts.ConstRequestStatus.Completed} flag is always set @todo: looks like USK subscribes will persist untill connection is closed. Can they be removed somehow? """ - msg = message.SubscribeUSK( + msg = message.MsgSubscribeUSK( URI=uri, DontPoll=dontPoll, ) - self._registerRequest(msg, consts.RequestType.SubscribeUSK) - msg['RequestStatus'] |= consts.RequestStatus.Completed + self._registerRequest(msg, consts.ConstRequestType.SubscribeUSK) + msg['RequestStatus'] |= consts.ConstRequestStatus.Completed self.sendMessage(msg) return msg['Identifier'] @@ -1529,22 +1519,22 @@ **msgParams ): """Uploads to the node - @param requestType: (L{consts.RequestType}). Can be PutData, PutDir or PutMultiple + @param requestType: (L{consts.ConstRequestType}). Can be PutData, PutDir or PutMultiple @param uri: (str) key or Uri - @param data: (str) for L{consts.RequestType.PutData} data to upload or None + @param data: (str) for L{consts.ConstRequestType.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 - @param items: for L{consts.RequestType.PutMultiple}, items to upload + @param items: for L{consts.ConstRequestType.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: - - RequestType: L{consts.RequestType.PutData}, L{consts.RequestType.PutFile} or L{consts.RequestType.PutRedirect} - - Data: if requestType is L{consts.RequestType.PutData}, data to upload - - Filename: if requestType is L{consts.RequestType.PutFile}, filepath of the file to upload - - TargetURI: if requestType is L{consts.RequestType.PutRedirect}, uri to redirect to + - RequestType: L{consts.ConstRequestType.PutData}, L{consts.ConstRequestType.PutFile} or L{consts.ConstRequestType.PutRedirect} + - Data: if requestType is L{consts.ConstRequestType.PutData}, data to upload + - Filename: if requestType is L{consts.ConstRequestType.PutFile}, filepath of the file to upload + - TargetURI: if requestType is L{consts.ConstRequestType.PutRedirect}, uri to redirect to - Name: name under wich the item will be accesible via freenet - Metadata.ContentType: (optional) may be passed as 'ContentType' @@ -1559,18 +1549,18 @@ 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 + if requestType & (consts.ConstRequestType.PutData | consts.ConstRequestType.PutFile | consts.ConstRequestType.PutRedirect): + msgClass = message.MsgClientPut + elif requestType == consts.ConstRequestType.PutDir: + msgClass = message.MsgClientPutDiskDir + elif requestType == consts.ConstRequestType.PutMultiple: + msgClass = message.MsgClientPutComplexDir else: raise ValueError('Unsupported request type') msg = msgClass(URI=uri) # add params - if uri.KeyType == consts.KeyType.CHK: + if uri.KeyType == consts.ConstKeyType.CHK: if uri.filename is not None: msg['TargetFilename'] = uri.filename for param, value in msgParams.items(): @@ -1578,32 +1568,32 @@ msg[param] = value if data is not None: - if requestType != consts.RequestType.PutData: + if requestType != consts.ConstRequestType.PutData: raise ValueError('Data can only be passed along with putData uploads') msg.data = data if items is not None: - if requestType != consts.RequestType.PutMultiple: + if requestType != consts.ConstRequestType.PutMultiple: raise ValueError('Items can only be passed along with PutMultiple uploads') uploadTypeMapping = { - consts.RequestType.PutData: consts.UploadFrom.Direct, - consts.RequestType.PutFile: consts.UploadFrom.Disk, - consts.RequestType.PutRedirect: consts.UploadFrom.Redirect, + consts.ConstRequestType.PutData: consts.ConstUploadFrom.Direct, + consts.ConstRequestType.PutFile: consts.ConstUploadFrom.Disk, + consts.ConstRequestType.PutRedirect: consts.ConstUploadFrom.Redirect, } # requestType --> [(allowedParam: boolParamIsRequired), ...] paramMapping = { - consts.RequestType.PutData: [ + consts.ConstRequestType.PutData: [ ('Name', True), ('Data', True), ('ContentType', False), ], - consts.RequestType.PutFile: [ + consts.ConstRequestType.PutFile: [ ('Name', True), ('Filename', True), ('Metadata.ContentType', False), ], - consts.RequestType.PutRedirect: [ + consts.ConstRequestType.PutRedirect: [ ('Name', True), ('TargetURI', True), ], @@ -1668,8 +1658,8 @@ contentType=None, dontCompress=None, maxRetries=None, - persistence=consts.Persistence.Connection, - priorityClass=consts.Priority.Medium, + persistence=consts.ConstPersistence.Connection, + priorityClass=consts.ConstPriority.Medium, userData=None, persistentUserData='', @@ -1682,7 +1672,7 @@ @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 priorityClass: (L{consts.ConstPriority}) 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 @@ -1693,7 +1683,7 @@ @event: (L{events.Events.RequestCompressionStarted}) triggered when the request is about to be compressed @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 + @note: if the upload is successful the node will create a L{consts.ConstKeyType.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. @@ -1701,7 +1691,7 @@ @todo: EarlyEncode and GetCHKOnly message params not implemented """ return self.clientPut( - consts.RequestType.PutData, + consts.ConstRequestType.PutData, uri, userData, persistentUserData, @@ -1718,8 +1708,8 @@ DontCompress=dontCompress, Persistence=persistence, PriorityClass=priorityClass, - UploadFrom=consts.UploadFrom.Direct, - Verbosity=consts.Verbosity.ReportProgress | consts.Verbosity.ReportCompression, + UploadFrom=consts.ConstUploadFrom.Direct, + Verbosity=consts.ConstVerbosity.ReportProgress | consts.ConstVerbosity.ReportCompression, ) @@ -1732,8 +1722,8 @@ dontCompress=None, maxRetries=None, - persistence=consts.Persistence.Connection, - priorityClass=consts.Priority.Medium, + persistence=consts.ConstPersistence.Connection, + priorityClass=consts.ConstPriority.Medium, targetFilename=None, userData=None, @@ -1756,7 +1746,7 @@ @todo: 2MiB compressed zize allowed? """ return self.clientPut( - consts.RequestType.PutDir, + consts.ConstRequestType.PutDir, uri, userData, persistentUserData, @@ -1773,8 +1763,8 @@ DontCompress=dontCompress, Persistence=persistence, PriorityClass=priorityClass, - UploadFrom=consts.UploadFrom.Disk, - Verbosity=consts.Verbosity.ReportProgress | consts.Verbosity.ReportCompression, + UploadFrom=consts.ConstUploadFrom.Disk, + Verbosity=consts.ConstVerbosity.ReportProgress | consts.ConstVerbosity.ReportCompression, ) @@ -1784,8 +1774,8 @@ contentType=None, dontCompress=None, maxRetries=None, - persistence=consts.Persistence.Connection, - priorityClass=consts.Priority.Medium, + persistence=consts.ConstPersistence.Connection, + priorityClass=consts.ConstPriority.Medium, userData=None, persistentUserData='', @@ -1800,7 +1790,7 @@ @todo: EarlyEncode and GetCHKOnly message params not implemented """ return self.clientPut( - consts.RequestType.PutFile, + consts.ConstRequestType.PutFile, uri, userData, persistentUserData, @@ -1816,8 +1806,8 @@ DontCompress=dontCompress, Persistence=persistence, PriorityClass=priorityClass, - UploadFrom=consts.UploadFrom.Disk, - Verbosity=consts.Verbosity.ReportProgress | consts.Verbosity.ReportCompression, + UploadFrom=consts.ConstUploadFrom.Disk, + Verbosity=consts.ConstVerbosity.ReportProgress | consts.ConstVerbosity.ReportCompression, ) def putMultiple(self, @@ -1827,8 +1817,8 @@ defaultName=None, dontCompress=None, maxRetries=None, - persistence=consts.Persistence.Connection, - priorityClass=consts.Priority.Medium, + persistence=consts.ConstPersistence.Connection, + priorityClass=consts.ConstPriority.Medium, targetFilename=None, userData=None, @@ -1843,10 +1833,10 @@ @note: for other params see L{putDir} @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} - - Data: if requestType is L{consts.RequestType.PutData}, data to upload - - Filename: if requestType is L{consts.RequestType.PutFile}, filepath of the file to upload - - TargetURI: if requestType is L{consts.RequestType.PutRedirect}, uri to redirect to + - RequestType: L{consts.ConstRequestType.PutData}, L{consts.ConstRequestType.PutFile} or L{consts.ConstRequestType.PutRedirect} + - Data: if requestType is L{consts.ConstRequestType.PutData}, data to upload + - Filename: if requestType is L{consts.ConstRequestType.PutFile}, filepath of the file to upload + - TargetURI: if requestType is L{consts.ConstRequestType.PutRedirect}, uri to redirect to - Name: name under wich the item will be accesible via freenet - Metadata.ContentType: (optional) may be passed as 'ContentType' @@ -1857,7 +1847,7 @@ @todo: EarlyEncode and GetCHKOnly message params not implemented """ return self.clientPut( - consts.RequestType.PutMultiple, + consts.ConstRequestType.PutMultiple, uri, userData, persistentUserData, @@ -1873,8 +1863,8 @@ DontCompress=dontCompress, Persistence=persistence, PriorityClass=priorityClass, - UploadFrom=consts.UploadFrom.Disk, - Verbosity=consts.Verbosity.ReportProgress | consts.Verbosity.ReportCompression, + UploadFrom=consts.ConstUploadFrom.Disk, + Verbosity=consts.ConstVerbosity.ReportProgress | consts.ConstVerbosity.ReportCompression, ) @@ -1883,8 +1873,8 @@ uri, targetKey, maxRetries=None, - persistence=consts.Persistence.Connection, - priorityClass=consts.Priority.Medium, + persistence=consts.ConstPersistence.Connection, + priorityClass=consts.ConstPriority.Medium, userData=None, persistentUserData='', ): @@ -1892,21 +1882,21 @@ @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 persistence: (L{consts.ConstPersistence}) of the request + @param priorityClass: (L{consts.ConstPriority}) 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, + consts.ConstRequestType.PutRedirect, uri, userData, persistentUserData, Persistence=persistence, PriorityClass=priorityClass, TargetURI=targetKey, - UploadFrom=consts.UploadFrom.Redirect, + UploadFrom=consts.ConstUploadFrom.Redirect, ) ######################################################## @@ -1917,7 +1907,7 @@ def getRequest(self, requestIdentifier): """Returns a (initial) message, given its identifier @param requestIdentifier: identifier of the message - @return: L{message.Message} + @return: L{message.MsgMessage} """ return self._requests[requestIdentifier] @@ -1933,25 +1923,25 @@ """Modifies a request @param requestIdentifier: identifier of the request to modify @param persistentUserData: (str) persistent user data or None - @param priorityClass: (L{consts.Priority}) new priority or None + @param priorityClass: (L{consts.ConstPriority}) new priority or None @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}. + @note: you can not change the priority of requests with Persistence=L{consts.ConstPersistence.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['RequestType'] & (consts.RequestType.MaskGet | consts.RequestType.MaskPut): + if not initialRequest['RequestType'] & (consts.ConstRequestType.MaskGet | consts.ConstRequestType.MaskPut): raise ValueError('Can not modify request: %s' % initialRequest.name) #FIX: [0002083] # 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: + if initialRequest['Persistence'] == consts.ConstPersistence.Connection: modified = {} #if priorityClass is not None: # raise ValueError('Can not modify priority of requests with Persistence=connection') @@ -1959,14 +1949,14 @@ if persistentUserData is not None: initialRequest['PersistentUserData'] = persistentUserData initialRequest['ClientToken'] = initialRequest.updatePersistentParams() - modified[consts.RequestModified.PersistentUserData] = None + modified[consts.ConstRequestModified.PersistentUserData] = None initialRequest['Modified'] = modified self.events.RequestModified(initialRequest) return #/FIX: [0002083] - msg = message.ModifyPersistentRequest( + msg = message.MsgModifyPersistentRequest( Identifier=initialRequest['Identifier'], Global=False, ) @@ -1984,10 +1974,10 @@ @param requestIdentifier: (str) identifier of the request to remove """ initialRequest = self._requests[requestIdentifier] - initialRequest['RequestStatus'] |= consts.RequestStatus.Removed | consts.RequestStatus.Completed - if initialRequest['RequestType'] & (consts.RequestType.MaskGet | consts.RequestType.MaskPut): + initialRequest['RequestStatus'] |= consts.ConstRequestStatus.Removed | consts.ConstRequestStatus.Completed + if initialRequest['RequestType'] & (consts.ConstRequestType.MaskGet | consts.ConstRequestType.MaskPut): self.sendMessage( - message.RemoveRequest( + message.MsgRemoveRequest( Global=False, Identifier=requestIdentifier, ) @@ -2012,7 +2002,7 @@ @param giveOpennetRef: if True, the opennet reference is retuned instead of the darknet """ self.sendMessage( - message.GetNode( + message.MsgGetNode( WithPrivate=withPrivate, WithVolatile=withVolatile, GiveOpennetRef=giveOpennetRef, @@ -2025,7 +2015,7 @@ @param identity: identity of the peer to request information for """ self.sendMessage( - message.ListPeer( + message.MsgListPeer( NodeIdentifier=identity, ) ) @@ -2039,7 +2029,7 @@ @note: listPeerNotes() is only available for darknet nodes """ self.sendMessage( - message.ListPeerNotes( + message.MsgListPeerNotes( NodeIdentifier=identity ) ) @@ -2054,7 +2044,7 @@ @event: EndListPeers(event, params). """ self.sendMessage( - message.ListPeers( + message.MsgListPeers( WithMetadata=withMetaData, WithVolatile=withVolantile, ) @@ -2071,7 +2061,7 @@ @note: you can only modify darknet peers """ msg = MessageEx( - message.ModifyPeer( + message.MsgModifyPeer( NodeIdentifier=identity, ) ) @@ -2092,10 +2082,10 @@ @note: you can only modify notes of darknet peers """ self.sendMessage( - message.ModifyPeerNote( + message.MsgModifyPeerNote( NodeIdentifier=identity, #NOTE: currently fcp supports only this one type - PeerNoteType=consts.PeerNoteType.Private, + PeerNoteType=consts.ConstPeerNoteType.Private, NoteText=note ) ) @@ -2106,7 +2096,7 @@ @param identity: identity of the peer node to remove """ self.sendMessage( - message.RemovePeer( + message.MsgRemovePeer( NodeIdentifier=identity, ) ) @@ -2122,11 +2112,11 @@ @param detailed: ... [truncated message content] |
From: <jU...@us...> - 2008-07-01 18:41:11
|
Revision: 474 http://fclient.svn.sourceforge.net/fclient/?rev=474&view=rev Author: jUrner Date: 2008-07-01 11:39:17 -0700 (Tue, 01 Jul 2008) Log Message: ----------- _newUuid() is now newidentifier() ++ this and that Modified Paths: -------------- trunk/fcp2/src/fcp2/client.py Modified: trunk/fcp2/src/fcp2/client.py =================================================================== --- trunk/fcp2/src/fcp2/client.py 2008-07-01 18:36:31 UTC (rev 473) +++ trunk/fcp2/src/fcp2/client.py 2008-07-01 18:39:17 UTC (rev 474) @@ -202,6 +202,7 @@ import logging import subprocess import time +import uuid #--> rel import hack @@ -220,12 +221,11 @@ from fcp2 import iohandler from fcp2 import types from fcp2 import key +import random from fcp2.fcp_lib import namespace from fcp2.fcp_lib import tools -from fcp2.fcp_lib import uuid - del hack, _RelImportHack #<-- rel import hack @@ -323,7 +323,6 @@ self.ioHandler.close() - #TODO: check if this method is still needed def _finalizeRequest(self, msg, request, event): """Finalzes a request @param msg: message that is the reason for finalizing @@ -350,21 +349,8 @@ if removeRequest: del self._requests[request['Identifier']] - - def _newUuid(self, uuids=None): - """Creates a new unique identifier - @param uuids: if desired any iterable containing uuids to enshure the identifier is unique in the iterable - @return: (str) uuid - - """ - uuid_ = uuid.uuid_time() - if uuids is not None: - while uuid_ in uuids: - uuid_ = uuid_time() - return uuid_ - def _registerRequest(self, msg, requestType, @@ -387,12 +373,12 @@ @return: (str) identifer of therequest @note: the identifier returned is unique to the client but may not be unique to the node """ - identifier = self._newUuid(uuids=self._requests) if identifier is None else identifier + identifier = self.newIdentifier(identifiers=self._requests) if identifier is None else identifier # equip requests with some additional params #TODO: keep an eye on additional params, they may collide with Fcp parameters - msg['Identifier'] = self._newUuid(uuids=self._requests) if identifier is None else identifier + msg['Identifier'] = self.newIdentifier(identifiers=self._requests) if identifier is None else identifier msg['RequestType'] = requestType msg['InitTime'] = time.time() if initTime is None else initTime if requestType & consts.ConstRequestType.MaskGet: @@ -459,9 +445,8 @@ @return: (bool) True if so, False otherwise """ return self.ioHandler.isOpen() + - - 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 @@ -537,7 +522,7 @@ @param connectionName: (str) connection name or None to use an arbitrary connection name @return: (str) connection name """ - self._connectionName = self._newUuid() if connectionName is None else connectionName + self._connectionName = self.newIdentifier() if connectionName is None else connectionName return self._connectionName @@ -548,15 +533,26 @@ return consts.ConstLogger.Client.getEffectiveLevel() - def setDebugVerbosity(self, debugVerbosity): """Sets the verbosity level of the client @param debugVerbosity: L{consts.ConstDebugVerbosity} """ consts.ConstLogger.Client.setLevel(debugVerbosity) - + + def newIdentifier(self, identifiers=None): + """Creates a new identifier to be used as request identifer or whatever + @param identifiersuuids: if desired any iterable containing identifiers to enshure the identifier is unique within the iterable + @return: (str) identifier + + """ + identifier = str(hex(random.getrandbits(128))) + if identifiers is not None: + while identifier in identifiers: + identifier = str(hex(random.getrandbits(128))) + return identifier + def startNode(self, cmdline): """Starts the freenet node @param cmdline: commandline to start freenet (like '/freenet/run.sh start' or 'c:\freenet\start.bat') @@ -612,7 +608,7 @@ return False # resend request with new identifier - newIdentifier = self._newUuid(uuids=self._requests) + newIdentifier = self.newIdentifier(identifiers=self._requests) self._requests[newIdentifier] = initialRequest del self._requests[requestIdentifier] initialRequest['Identifier'] = newIdentifier @@ -764,6 +760,7 @@ raise ValueError('No initial message found in TestDDAComplete') # remove test and clean tmp data + #TODO: reset TestDDA params or not? self._ddaTests.remove(initialRequest) if initialRequest['TestDDA']['TmpFile'] is not None: tools.saveRemoveFile(initialRequest['TestDDA']['TmpFile']) @@ -847,7 +844,9 @@ code = msg['Code'] if code == consts.ConstFetchError.Canceled: - initialRequest['RequestStatus'] |= consts.ConstRequestStatus.Removed | consts.ConstRequestStatus.Completed | consts.ConstRequestStatus.RemovedFromQueue + initialRequest['RequestStatus'] |= consts.ConstRequestStatus.Removed | \ + consts.ConstRequestStatus.Completed | \ + consts.ConstRequestStatus.RemovedFromQueue del self._requests[requestIdentifier] self.events.RequestRemoved(initialRequest) return True @@ -897,7 +896,7 @@ self.events.RequestRestored(initialRequest) return True - # ignore + #TODO: ignore handshake? return False @@ -1196,8 +1195,8 @@ # Reminder to self: # - # if socket dies on sendall ther is no way to determine if and how much data was send - # ...so assume data was send, cos there is no way to proove it was not send + # if socket dies on sendall there is no way to determine if and how much data was send + # ...so assume data was send try: self.ioHandler.sendMessage(msg) except consts.ErrorIOBroken, details: @@ -1237,9 +1236,8 @@ WithDataTypes=withDataTypes, ) ) + - - def modifyConfig(self, params): """Modifies node configuration values @param params: (dict) containing parameters to modify @@ -1286,7 +1284,6 @@ ) self.sendMessage(msg) return msg['Identifier'] - def getData(self, @@ -1352,8 +1349,7 @@ ReturnType=consts.ConstReturnType.Direct, Verbosity=consts.ConstVerbosity.ReportProgress, ) - - + def getFile(self, uri, @@ -1424,7 +1420,6 @@ ) - def getKeyInfo(self, uri, @@ -1482,7 +1477,6 @@ ) - def subscribeUSK(self, uri, dontPoll=True): """Asks the node to notify the client when an USK is updated @param uri: (L{key.USK}) key to subscribe to @@ -1868,7 +1862,6 @@ ) - def putRedirect(self, uri, targetKey, @@ -1984,8 +1977,7 @@ ) else: del self._requests[requestIdentifier] - - + ######################################################## ## ## Peer related methods This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-02 07:04:37
|
Revision: 478 http://fclient.svn.sourceforge.net/fclient/?rev=478&view=rev Author: jUrner Date: 2008-07-02 00:04:45 -0700 (Wed, 02 Jul 2008) Log Message: ----------- fixed broken docstrings Modified Paths: -------------- trunk/fcp2/src/fcp2/client.py Modified: trunk/fcp2/src/fcp2/client.py =================================================================== --- trunk/fcp2/src/fcp2/client.py 2008-07-01 18:48:31 UTC (rev 477) +++ trunk/fcp2/src/fcp2/client.py 2008-07-02 07:04:45 UTC (rev 478) @@ -432,7 +432,7 @@ @param duration: (int) how many seconds try to connect before giving up @param timeout: (int) how much time to wait before another attempt to connect - @return: (L{message.MsgMessage}) NodeHello or None if no connection could be established + @return: (L{message.MsgNodeHello}) or None if no connection could be established """ nodeHello = None for nodeHello in self.iterConnect(host=host, port=port, duration=duration, timeout=timeout): @@ -454,7 +454,7 @@ @param duration: (int) how many seconds try to connect before giving up @param timeout: (int) how much time to wait before another attempt to connect - @return: (L{message.MsgMessage}) NodeHello if successful, None otherwise for the next iteration + @return: (L{message.MsgNodeHello}) if successful, None otherwise for the next iteration @event: ClientConnected(event, message) is triggered as soon as the client is connected """ @@ -542,7 +542,7 @@ def newIdentifier(self, identifiers=None): """Creates a new identifier to be used as request identifer or whatever - @param identifiersuuids: if desired any iterable containing identifiers to enshure the identifier is unique within the iterable + @param identifiers: if desired any iterable containing identifiers to enshure the identifier is unique within the iterable @return: (str) identifier """ @@ -1185,8 +1185,8 @@ def sendMessage(self, msg): """Sends a message to freenet - @param msg: (L{message.MsgMessage}) message to send - @return: (L{message.MsgMessage}) disconnect if something went wrong + @param msg: (L{message._MessageBase}) message to send + @return: always None @note: If an error occurs the client is closed @note: you can use this method to send a message to the node, bypassing all @@ -1260,7 +1260,7 @@ **messageParams ): """Requests a key from the node - @param uri: (L{key.KeyBase}) key to request + @param uri: (L{key._KeyBase}) key to request @param requestType: (L{consts.ConstRequestType}) 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 @@ -1303,7 +1303,7 @@ ): """Requests datae from the node - @param uri: (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 @@ -1370,7 +1370,7 @@ ): """Requests a file from the node - @param uri: (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 @@ -1434,7 +1434,7 @@ ): """Requests info about a key - @param uri: (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 @@ -1479,7 +1479,7 @@ def subscribeUSK(self, uri, dontPoll=True): """Asks the node to notify the client when an USK is updated - @param uri: (L{key.USK}) key to subscribe to + @param uri: (L{key.KeyUSK}) key to subscribe to @param dontPoll: if True, does whatever ??? @return: (str) identifer of the request @@ -1660,7 +1660,7 @@ ): """Uploads data - @param uri: (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 @@ -1726,7 +1726,7 @@ ): """Uploads the contents of a directory - @param uri: (L{key.KeyBase}) key under wich to upload the 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 @@ -1776,7 +1776,7 @@ ): """Uploads a file - @param uri: (L{key.KeyBase}) key under wich to upload the file + @param uri: (L{key._KeyBase}) key under wich to upload the file @param filename: (str) file to upload @note: for other params see L{putData} @@ -1821,7 +1821,7 @@ ): """Uploads multiple items at once to be retrievable under one key - @param uri: (L{key.KeyBase}) key under wich to upload the file + @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{putDir} @@ -1872,7 +1872,7 @@ persistentUserData='', ): """Uploads a redirect to another key - @param uri: (L{key.KSK}) to insert as redirect + @param uri: (L{key.KeyKSK}) 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.ConstPersistence}) of the request @@ -1900,7 +1900,7 @@ def getRequest(self, requestIdentifier): """Returns a (initial) message, given its identifier @param requestIdentifier: identifier of the message - @return: L{message.MsgMessage} + @return: L{message._MessageBase} """ return self._requests[requestIdentifier] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-04 08:26:20
|
Revision: 488 http://fclient.svn.sourceforge.net/fclient/?rev=488&view=rev Author: jUrner Date: 2008-07-04 01:26:26 -0700 (Fri, 04 Jul 2008) Log Message: ----------- adapt to changes in key.py Modified Paths: -------------- trunk/fcp2/src/fcp2/client.py Modified: trunk/fcp2/src/fcp2/client.py =================================================================== --- trunk/fcp2/src/fcp2/client.py 2008-07-04 08:25:43 UTC (rev 487) +++ trunk/fcp2/src/fcp2/client.py 2008-07-04 08:26:26 UTC (rev 488) @@ -1085,8 +1085,9 @@ requestURI = msg['RequestURI'] if initialRequest['RequestType'] == consts.ConstRequestType.GenerateUSKKeypair: - insertURI = key.KeyUSK(insertURI.keyData, filename=insertURI.filename) - requestURI = key.KeyUSK(requestURI.keyData, filename=requestURI.filename) + insertURI = key.KeyUSK(insertURI.keyData, docName=insertURI.docName) + insertURI = key.KeyUSK(insertURI.keyData, docName=insertURI.docName) + requestURI = key.KeyUSK(requestURI.keyData, docName=requestURI.docName) initialRequest['InsertURI'] = insertURI initialRequest['RequestURI'] = requestURI initialRequest['RequestStatus'] |= consts.ConstRequestStatus.Success @@ -1556,7 +1557,7 @@ # add params if uri.KeyType == consts.ConstKeyType.CHK: if uri.filename is not None: - msg['TargetFilename'] = uri.filename + msg['TargetFilename'] = uri.docName for param, value in msgParams.items(): if value is not None: msg[param] = value This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-05 10:46:11
|
Revision: 495 http://fclient.svn.sourceforge.net/fclient/?rev=495&view=rev Author: jUrner Date: 2008-07-05 03:46:19 -0700 (Sat, 05 Jul 2008) Log Message: ----------- fix. complain that on ClientPut key.tail is disallowed Modified Paths: -------------- trunk/fcp2/src/fcp2/client.py Modified: trunk/fcp2/src/fcp2/client.py =================================================================== --- trunk/fcp2/src/fcp2/client.py 2008-07-05 10:45:22 UTC (rev 494) +++ trunk/fcp2/src/fcp2/client.py 2008-07-05 10:46:19 UTC (rev 495) @@ -1554,10 +1554,20 @@ raise ValueError('Unsupported request type') msg = msgClass(URI=uri) - # add params + # if uri.KeyType == consts.ConstKeyType.CHK: + if uri.tail is not None: + raise valueError('no tail allowed') if uri.filename is not None: msg['TargetFilename'] = uri.docName + elif uri.KeyType == consts.ConstKeyType.SSK: + if uri.tail is not None: + raise valueError('no tail allowed') + elif uri.KeyType == consts.ConstKeyType.USK: + if uri.tail is not None: + raise valueError('no tail allowed') + + # add params for param, value in msgParams.items(): if value is not None: msg[param] = value This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-05 11:17:36
|
Revision: 496 http://fclient.svn.sourceforge.net/fclient/?rev=496&view=rev Author: jUrner Date: 2008-07-05 04:17:44 -0700 (Sat, 05 Jul 2008) Log Message: ----------- fixed typo Modified Paths: -------------- trunk/fcp2/src/fcp2/client.py Modified: trunk/fcp2/src/fcp2/client.py =================================================================== --- trunk/fcp2/src/fcp2/client.py 2008-07-05 10:46:19 UTC (rev 495) +++ trunk/fcp2/src/fcp2/client.py 2008-07-05 11:17:44 UTC (rev 496) @@ -1557,15 +1557,15 @@ # if uri.KeyType == consts.ConstKeyType.CHK: if uri.tail is not None: - raise valueError('no tail allowed') + raise ValueError('no tail allowed') if uri.filename is not None: msg['TargetFilename'] = uri.docName elif uri.KeyType == consts.ConstKeyType.SSK: if uri.tail is not None: - raise valueError('no tail allowed') + raise ValueError('no tail allowed') elif uri.KeyType == consts.ConstKeyType.USK: if uri.tail is not None: - raise valueError('no tail allowed') + raise ValueError('no tail allowed') # add params for param, value in msgParams.items(): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-05 11:19:31
|
Revision: 497 http://fclient.svn.sourceforge.net/fclient/?rev=497&view=rev Author: jUrner Date: 2008-07-05 04:19:36 -0700 (Sat, 05 Jul 2008) Log Message: ----------- user data is optional Modified Paths: -------------- trunk/fcp2/src/fcp2/client.py Modified: trunk/fcp2/src/fcp2/client.py =================================================================== --- trunk/fcp2/src/fcp2/client.py 2008-07-05 11:17:44 UTC (rev 496) +++ trunk/fcp2/src/fcp2/client.py 2008-07-05 11:19:36 UTC (rev 497) @@ -1507,8 +1507,8 @@ def clientPut(self, requestType, uri, - userData, - persistentUserData, + userData=None, + persistentUserData=None, data=None, items=None, **msgParams @@ -1517,8 +1517,8 @@ @param requestType: (L{consts.ConstRequestType}). Can be PutData, PutDir or PutMultiple @param uri: (str) key or Uri @param data: (str) for L{consts.ConstRequestType.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 + @param persistentUserData: (str) persistent data to be assosiated to the requestor None + @param userData: (any) any data to be associated to the request at runtime or None @param items: for L{consts.ConstRequestType.PutMultiple}, items to upload @param msgParams: (dict) Fcp parameters to pass along with the message This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-05 18:57:10
|
Revision: 505 http://fclient.svn.sourceforge.net/fclient/?rev=505&view=rev Author: jUrner Date: 2008-07-05 11:56:29 -0700 (Sat, 05 Jul 2008) Log Message: ----------- update min node build Modified Paths: -------------- trunk/fcp2/src/fcp2/client.py Modified: trunk/fcp2/src/fcp2/client.py =================================================================== --- trunk/fcp2/src/fcp2/client.py 2008-07-05 12:45:13 UTC (rev 504) +++ trunk/fcp2/src/fcp2/client.py 2008-07-05 18:56:29 UTC (rev 505) @@ -253,7 +253,7 @@ """ ExpectedFcpVersion = 2.0 - ExpectedNodeBuild = 1107 + ExpectedNodeBuild = 1153 DefaultFcpHost = os.environ.get('FCP_HOST', '127.0.0.1') DefaultFcpPort = int(os.environ.get('FCP_PORT', '9481')) MaxSizeKeyInfo = 32768 @@ -277,9 +277,10 @@ """ self._connectionName = self.setConnectionName(connectionName) self._ddaTests = [] # currently running DDA tests (request0, ... requestN) - self.events = events.Events() self._nodeHelloMessage = None self._requests = {} # currently running requests (requestIdentifier --> request) + + self.events = events.Events() self.ioHandler = iohandler.IOHandler() for event in self.events: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-05 21:18:16
|
Revision: 506 http://fclient.svn.sourceforge.net/fclient/?rev=506&view=rev Author: jUrner Date: 2008-07-05 14:18:25 -0700 (Sat, 05 Jul 2008) Log Message: ----------- a few notes Modified Paths: -------------- trunk/fcp2/src/fcp2/client.py Modified: trunk/fcp2/src/fcp2/client.py =================================================================== --- trunk/fcp2/src/fcp2/client.py 2008-07-05 18:56:29 UTC (rev 505) +++ trunk/fcp2/src/fcp2/client.py 2008-07-05 21:18:25 UTC (rev 506) @@ -186,6 +186,7 @@ #------------------------------------------------------------------------------------------------------------------------------------------------- + # reminders to self #------------------------------------------------------------------------------------------------------------------------------------------------ # Key() @@ -193,8 +194,14 @@ # we do not allow passing strings as uris. putting a CHK gets in the way here. would have to add another # special case to handle 'CHK@myfilename' on input. so for uniformity reasons keys are enforced. #------------------------------------------------------------------------------------------------------------------------------------------------ +# clientGet('USK@.../whatever/-1') +# +# will trigger a FetchError(PermanentRedirect) with the highest available version as RedirectURI +# we don't handle this automatically, cos it could be the desired result. maybe implement a flag +# someday to handle this +# +#------------------------------------------------------------------------------------------------------------------------------------------------ - import os, sys import atexit This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-06 05:53:58
|
Revision: 518 http://fclient.svn.sourceforge.net/fclient/?rev=518&view=rev Author: jUrner Date: 2008-07-05 22:54:07 -0700 (Sat, 05 Jul 2008) Log Message: ----------- fix import Modified Paths: -------------- trunk/fcp2/src/fcp2/client.py Modified: trunk/fcp2/src/fcp2/client.py =================================================================== --- trunk/fcp2/src/fcp2/client.py 2008-07-06 05:52:55 UTC (rev 517) +++ trunk/fcp2/src/fcp2/client.py 2008-07-06 05:54:07 UTC (rev 518) @@ -230,7 +230,7 @@ from fcp2 import key import random -from fcp2.fcp_lib import namespace +from fcp2.lib import namespace from fcp2.lib import tools del hack, _RelImportHack This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |