SF.net SVN: fclient: [95] trunk/sandbox/fcp/fcp2_0_client.py
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <ju...@us...> - 2008-01-30 17:17:08
|
Revision: 95
http://fclient.svn.sourceforge.net/fclient/?rev=95&view=rev
Author: jurner
Date: 2008-01-30 09:17:10 -0800 (Wed, 30 Jan 2008)
Log Message:
-----------
thises and thats
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-01-30 17:16:34 UTC (rev 94)
+++ trunk/sandbox/fcp/fcp2_0_client.py 2008-01-30 17:17:10 UTC (rev 95)
@@ -1043,20 +1043,14 @@
WithLongDescription=withLongDescription,
)
- def getNode(self,
- withPrivate=True,
- withVolatile=True,
- giveOpennetRef=True,
- ):
+
+ def modifyConfig(self, params):
+ """Modifies node configuration values
+ @param params: (dict) containing parameters to modify
"""
- @event: NodeData(event, msg)
- """
- self.sendMessage(
- self.Message.MessageGetNode,
- WithPrivate=self.fcpBool(withPrivate),
- WithVolatile=self.fcpBool(withVolatile),
- GiveOpennetRef=self.fcpBool(giveOpennetRef),
- )
+ msg = self.Message(self.Message.MessageModifyConfig)
+ msg.params = params
+ self.sendMessageEx(msg)
########################################################
@@ -1427,22 +1421,35 @@
#TODO: check how Fcp responds when the identifier is unknwon or something else goes
# werong. Maybe a ProtocolError.NoSuchIdentifier ???
+
+
########################################################
##
## Peer related methods
##
########################################################
- def getNode(self, withPrivate=True, withVolantile=True):
+ def getNode(self,
+ withPrivate=True,
+ withVolatile=True,
+ giveOpennetRef=True,
+ ):
+ """Request information about the node
+ @param withPrivate: if True, private data is included
+ @param withVolatile: if True, statistical data is included
+ @param giveOppennetRef: if True, the opennet reference is retuned instead of the darknet
+ """
self.sendMessage(
- self.Message.MessageGetNode,
- WithPrivate=withPrivate,
- WithVolatile=withVolantile,
- )
-
-
+ self.Message.MessageGetNode,
+ WithPrivate=withPrivate,
+ WithVolatile=withVolatile,
+ GiveOpennetRef=giveOpennetRef,
+ )
def listPeer(self, identity):
+ """Requests information about a peer node
+ @param identifier: identifier of the peer to request information for
+ """
self.jobClient.sendMessage(
self.Message.MessageListPeer,
NodeIdentifier=identity,
@@ -1478,21 +1485,31 @@
def modifyPeer(self, identity, allowLocalAddresses=None, isDisabled=None, isListenOnly=None):
+ """Modifies a peer node
+ @param identity: 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
+ """
msg = Message(
self.Message.MessageModifyPeer,
NodeIdentifier=identity,
)
if allowLocalAddresses is not None:
- msg['AllowLocalAddresses'] = self.fcpBool(allowLocalAddresses)
+ msg['AllowLocalAddresses'] = allowLocalAddresses
if isDisabled is not None:
- msg['isDisabled'] = self.fcpBool(isDisabled)
+ msg['isDisabled'] = isDisabled
if isListenOnly is not None:
- msg['isListenOnly'] = self.fcpBool(isListenOnly)
+ msg['isListenOnly'] = isListenOnly
self.jobClient.sendMessageEx(msg)
self.sendMessageEx(msg)
def modifyPeerNote(self, identity, note):
+ """Modifies the note associated to a peer
+ @param identity: identity of the peer node to modify
+ @param note: (str) new note to associate to the peer
+ """
self.sendMessage(
self.Message.MessageModifyPeerNote,
NodeIdentifier=identity,
@@ -1503,6 +1520,9 @@
def removePeer(self, identity):
+ """Removes a peer
+ @param identity: identity of the peer node to remove
+ """
self.sendMessage(
self.Message.MessageRemovePeer,
NodeIdentifier=identity,
@@ -1624,16 +1644,25 @@
def cb(event, msg):
root=Config(configDataMsg=msg)
+
+ print
+ print '***************************************'
+ print '* walking config tree'
+ print '***************************************'
for node in root.walk():
- key = node.key()
- if key is None: # skip root
+ if node.name is None: # skip root
continue
- print key
- for keyName, values in sorted(node.values.items()):
- print ' ' + keyName
- for valueClass, (value, valueType) in sorted(values.items()):
- print ' %s=%r (%s)' % (valueClass, value, valueType)
-
+ print node.key()
+ for valueClass, (value, valueType) in sorted(node.values.items()):
+ print ' %s=%r (%s)' % (valueClass, value, valueType)
+
+ print
+ print '***************************************'
+ print '* generating dict from config tree'
+ print '***************************************'
+ for key, value in root.toMessageParams().items():
+ print '%s: %s (%s)' % (key, value, type(value))
+
#c.setDebugVerbosity(c.DebugVerbosity.Warning)
c.events.ConfigData += cb
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|