SF.net SVN: fclient: [58] trunk/fclient/fclient_lib/fcp/fcp2_0.py
Status: Pre-Alpha
Brought to you by:
jurner
From: <jU...@us...> - 2007-11-08 11:12:52
|
Revision: 58 http://fclient.svn.sourceforge.net/fclient/?rev=58&view=rev Author: jUrner Date: 2007-11-08 03:12:56 -0800 (Thu, 08 Nov 2007) Log Message: ----------- protocol errors in relation to requests are now passed to the caller ++ some renames Modified Paths: -------------- trunk/fclient/fclient_lib/fcp/fcp2_0.py Modified: trunk/fclient/fclient_lib/fcp/fcp2_0.py =================================================================== --- trunk/fclient/fclient_lib/fcp/fcp2_0.py 2007-11-07 17:35:34 UTC (rev 57) +++ trunk/fclient/fclient_lib/fcp/fcp2_0.py 2007-11-08 11:12:56 UTC (rev 58) @@ -146,6 +146,8 @@ 'ClientConnected', 'ClientDisconnected', + 'ProtocolError', + # config related events 'ConfigData', 'NodeData', @@ -164,8 +166,8 @@ 'TestDDAComplete', 'IdentifierCollision', - 'ClientGetInfo', - 'ClientGetInfoProgress', + 'ClientRequestInfo', + 'ClientRequestInfoProgress', 'DataFound', 'GetFailed', @@ -319,7 +321,7 @@ class IdentifierPrefix: """Special purpose identifier prefixes""" - ClientGetInfo = 'ClientGetInfo::' + ClientRequestInfo = 'ClientRequestInfo::' class InsertError(Exception): """All insert errors supported by the client""" @@ -797,8 +799,14 @@ self.events.ClientDisconnect({'DisconnectReason': DisconnectReason.Shutdown}) return True - raise self.ProtocolError(msg) + identifier = msg.get('Identifier', None) + if identifier is None: + #TODO: check how to handle this + raise self.ProtocolError(msg) + else: + self.events.ProtocolError(msg.params) + #################################################### ## ## TestDDA @@ -888,8 +896,8 @@ ## #################################################### elif msg.name == self.Message.DataFound: - if msg['Identifier'].startswith(self.IdentifierPrefix.ClientGetInfo): - self.events.ClientGetInfo(msg.params) + if msg['Identifier'].startswith(self.IdentifierPrefix.ClientRequestInfo): + self.events.ClientRequestInfo(msg.params) return True self.events.DataFound(msg.params) @@ -898,21 +906,21 @@ elif msg.name == self.Message.GetFailed: code = msg['Code'] if code == self.FetchError.TooBig: - if msg['Identifier'].startswith(self.IdentifierPrefix.ClientGetInfo): + if msg['Identifier'].startswith(self.IdentifierPrefix.ClientRequestInfo): params = { 'Identifier': msg['Identifier'], 'Metadata.ContentType': msg.get('ExpectedMetadata.ContentType', ''), 'DataLength': msg.get('ExpectedDataLength', '') } - self.events.ClientGetInfo(params) + self.events.ClientRequestInfo(params) return True self.events.GetFailed(msg.params) return True elif msg.name == self.Message.SimpleProgress: - if msg['Identifier'].startswith(self.IdentifierPrefix.ClientGetInfo): - self.events.ClientGetInfoProgress(msg.params) + if msg['Identifier'].startswith(self.IdentifierPrefix.ClientRequestInfo): + self.events.ClientRequestInfoProgress(msg.params) else: self.events.SimpleProgress(msg.params) return True @@ -1211,7 +1219,7 @@ return identifier - def clientGetInfo(self, uri, **params): + def clientRequestInfo(self, uri, **params): """Requests info about a file @param uri: uri of the file to request info about @event: clientGetInfo(event, params). If success, params will contain a key 'Metadata.ContentType' @@ -1220,7 +1228,7 @@ @note: for other events see: L{clientGet} @return: (str) request identifier """ - identifier = self.IdentifierPrefix.ClientGetInfo + self.newIdentifier() + identifier = self.IdentifierPrefix.ClientRequestInfo + self.newIdentifier() self.sendMessage( self.Message.ClientGet, Identifier=identifier, @@ -1394,13 +1402,13 @@ #testListPeerNotes() - def testClientGetInfo(): + def testClientRequestInfo(): def cb(event, params): print params c.events.ClientGetInfo += cb - identifier = c.clientGetInfo('CHK@sdNenKGj5mupxaSwo44jcW8dsX7vYTLww~BsRPtur0k,ZNRm9reMjtKEl9e-xFByKXbW6q4f6OQyfg~l9GRSAes,AAIC--8/snow_002%20%281%29.jpg') + identifier = c.clientRequestInfo('CHK@sdNenKGj5mupxaSwo44jcW8dsX7vYTLww~BsRPtur0k,ZNRm9reMjtKEl9e-xFByKXbW6q4f6OQyfg~l9GRSAes,AAIC--8/snow_002%20%281%29.jpg') for i in xrange(20): c.next() - #testClientGetInfo() + #testClientRequestInfo() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |