SF.net SVN: fclient: [180] trunk/sandbox/fcp/fcp2_0_client.py
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <ju...@us...> - 2008-02-08 09:13:35
|
Revision: 180
http://fclient.svn.sourceforge.net/fclient/?rev=180&view=rev
Author: jurner
Date: 2008-02-08 01:13:40 -0800 (Fri, 08 Feb 2008)
Log Message:
-----------
combed a bit over Peer related stuff ++ UnknownPeerNoteType is handled now
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-08 09:11:42 UTC (rev 179)
+++ trunk/sandbox/fcp/fcp2_0_client.py 2008-02-08 09:13:40 UTC (rev 180)
@@ -660,9 +660,9 @@
if requestIdentifier is None:
- #TODO: check how to handle this
- raise consts.ProtocolError(msg)
-
+ self.events.ProtocolError(msg)
+ return True
+
if initialRequest is None:
return False
@@ -1104,6 +1104,9 @@
self.events.PeerUnknown(msg)
return True
+ elif msg.name == consts.Message.UnknownPeerNoteType:
+ self.events.PeerNoteTypeUnknown(msg)
+ return True
####################################################
##
## plugins
@@ -1208,14 +1211,11 @@
# check if we have running requests. Assert False
haveRunningRequests = False
- #print 'run'
for request in self._requests.values():
- #print 'is completed', request.params['FcRequestStatus'] & consts.RequestStatus.Completed
if not request.params['FcRequestStatus'] & consts.RequestStatus.Completed:
haveRunningRequests = True
break
- #print 'haveRunningRequest', haveRunningRequests
if not haveRunningRequests:
self._log.info(consts.LogMessages.AllRequestsCompleted)
break
@@ -1939,9 +1939,9 @@
)
- def listPeer(self, nodeIdentity):
+ def listPeer(self, identity):
"""Requests information about a peer node
- @param nodeIdentity: identity of the peer to request information for
+ @param identity: identity of the peer to request information for
"""
self.sendMessage(
consts.Message.ListPeer,
@@ -1949,16 +1949,16 @@
)
- def listPeerNotes(self, nodeIdentity):
+ def listPeerNotes(self, identity):
"""Lists all text notes associated to a peer
- @param nodeIdentity: peer as returned in a call to L{listPeer}
+ @param identity: peer as returned in a call to L{listPeer}
@event: ListPeerNote(event, params)
@event: EndListPeerNotes(event, params)
@note: listPeerNotes() is only available for darknet nodes
"""
self.sendMessage(
consts.Message.ListPeerNotes,
- NodeIdentifier=nodeIdentity
+ NodeIdentifier=identity
)
@@ -1978,16 +1978,18 @@
- def modifyPeer(self, nodeIdentifier, allowLocalAddresses=None, isDisabled=None, isListenOnly=None):
+ def modifyPeer(self, identitty, allowLocalAddresses=None, isDisabled=None, isListenOnly=None):
"""Modifies a peer node
- @param nodeIdentifier: identitfier of the peer node to modify
+ @param identitty: identity of the peer node to modify
@param allowLocalAddresses: if True, whatever is done
@param isDisabled: if True, the peer is disabled
@param isListenOnly: if True, the peer is set to listen only status
+
+ @note: you can only modify darknet peers
"""
msg = Message(
consts.Message.ModifyPeer,
- NodeIdentifier=nodeidentifier,
+ NodeIdentifier=identity,
)
if allowLocalAddresses is not None:
msg['AllowLocalAddresses'] = allowLocalAddresses
@@ -1998,27 +2000,29 @@
self.sendMessageEx(msg)
- def modifyPeerNote(self, nodeIdentifier, note):
+ def modifyPeerNote(self, identity, note):
"""Modifies the note associated to a peer
- @param nodeIdentifier: identitifier of the peer node to modify
+ @param identity: identity of the peer node to modify
@param note: (str) new note to associate to the peer
+
+ @note: you can only modify notes of darknet peers
"""
self.sendMessage(
consts.Message.ModifyPeerNote,
- NodeIdentifier=nodeIdentifier,
+ NodeIdentifier=identity,
#NOTE: currently fcp supports only this one type
PeerNoteType=consts.PeerNoteType.Private,
NoteText=note
)
- def removePeer(self, nodeIdentifier):
+ def removePeer(self, identity):
"""Removes a peer
- @param nodeIdentifier: identitfier of the peer node to remove
+ @param identity: identity of the peer node to remove
"""
self.sendMessage(
consts.Message.RemovePeer,
- NodeIdentifier=nodeidentifier,
+ NodeIdentifier=identity,
)
##########################################################
@@ -2356,8 +2360,16 @@
def testListPeers():
+
+ def peerCb(event, msg):
+ c.listPeerNotes(msg['identity'])
+
+ c.events.Peer += peerCb
c.listPeers()
- for i in xrange(10):
+
+
+
+ for i in xrange(50):
c.next()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|