Thread: SF.net SVN: fclient: [269] trunk/sandbox/fcp2/types.py
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <ju...@us...> - 2008-02-26 14:45:30
|
Revision: 269
http://fclient.svn.sourceforge.net/fclient/?rev=269&view=rev
Author: jurner
Date: 2008-02-26 06:45:27 -0800 (Tue, 26 Feb 2008)
Log Message:
-----------
moved ConfigValueClasses to consts
Modified Paths:
--------------
trunk/sandbox/fcp2/types.py
Modified: trunk/sandbox/fcp2/types.py
===================================================================
--- trunk/sandbox/fcp2/types.py 2008-02-26 14:45:05 UTC (rev 268)
+++ trunk/sandbox/fcp2/types.py 2008-02-26 14:45:27 UTC (rev 269)
@@ -236,27 +236,7 @@
"""Parameter --> FcpType mapping for config related messages"""
ComponentSep = '.'
-
- # first component of a config message param is always the param class
- ParamClassCurrent = 'current'
- ParamClassDefault = 'default'
- ParamClassExpertFlag = 'expertFlag'
- ParamClassForceWriteFlag = 'forceWriteFlag'
- ParamClassShortDescription = 'shortDescription'
- ParamClassLongDescription = 'longDescription'
- ParamClassSortOrder = 'sortOrder'
-
- ParamClasses = (
- ParamClassCurrent,
- ParamClassDefault,
- ParamClassExpertFlag,
- ParamClassForceWriteFlag,
- ParamClassShortDescription,
- ParamClassLongDescription,
- ParamClassSortOrder,
- )
-
# all known config keys (param class stripped)
Params = {
@@ -399,7 +379,7 @@
"""
result = paramName.split(self.ComponentSep, 1)
if len(result) == 2:
- if result[0] in self.ParamClasses:
+ if result[0] in consts.ConfigValueClass.ClassesAll:
return result
return '', paramName
@@ -421,20 +401,22 @@
@return: (FcpType)
"""
paramClass, paramKey = self.splitParamClass(paramName)
- if paramClass == self.ParamClassCurrent or paramClass == '':
+ if paramClass == consts.ConfigValueClass.Current or paramClass == '':
return self.Params[paramKey]
- elif paramClass == self.ParamClassDefault:
+ elif paramClass == consts.ConfigValueClass.Default:
return self.Params[paramKey]
- elif paramClass == self.ParamClassExpertFlag:
+ elif paramClass == consts.ConfigValueClass.ExpertFlag:
return FcpTypeBool
- elif paramClass == self.ParamClassForceWriteFlag:
+ elif paramClass == consts.ConfigValueClass.ForceWriteFlag:
return FcpTypeBool
- elif paramClass == self.ParamClassShortDescription:
+ elif paramClass == consts.ConfigValueClass.ShortDescription:
return FcpTypeString
- elif paramClass == self.ParamClassLongDescription:
+ elif paramClass == consts.ConfigValueClass.LongDescription:
return FcpTypeString
- elif paramClass == self.ParamClassSortOrder:
+ elif paramClass == consts.ConfigValueClass.SortOrder:
return FcpTypeInt
+ elif paramClass == consts.ConfigValueClass.DataType:
+ return FcpTypeString
else:
raise ValueError('Unknown param class in: %r' % paramName)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ju...@us...> - 2008-02-26 14:48:14
|
Revision: 271
http://fclient.svn.sourceforge.net/fclient/?rev=271&view=rev
Author: jurner
Date: 2008-02-26 06:48:13 -0800 (Tue, 26 Feb 2008)
Log Message:
-----------
added another new config setting ...Freenet devels seem busy
Modified Paths:
--------------
trunk/sandbox/fcp2/types.py
Modified: trunk/sandbox/fcp2/types.py
===================================================================
--- trunk/sandbox/fcp2/types.py 2008-02-26 14:45:54 UTC (rev 270)
+++ trunk/sandbox/fcp2/types.py 2008-02-26 14:48:13 UTC (rev 271)
@@ -291,6 +291,7 @@
'node.downloadAllowedDirs': FcpTypeChoiceNodeDownloadAllowedDirs,
'node.downloadsDir': FcpTypeDirname,
'node.enableARKs': FcpTypeBool,
+ 'node.enablePacketCoalescing': FcpTypeBool,
'node.enablePerNodeFailureTables': FcpTypeBool,
'node.enableSwapping': FcpTypeBool,
'node.enableSwapQueueing': FcpTypeBool,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ju...@us...> - 2008-02-26 18:58:11
|
Revision: 282
http://fclient.svn.sourceforge.net/fclient/?rev=282&view=rev
Author: jurner
Date: 2008-02-26 10:54:12 -0800 (Tue, 26 Feb 2008)
Log Message:
-----------
moved config key sep to consts
Modified Paths:
--------------
trunk/sandbox/fcp2/types.py
Modified: trunk/sandbox/fcp2/types.py
===================================================================
--- trunk/sandbox/fcp2/types.py 2008-02-26 18:53:55 UTC (rev 281)
+++ trunk/sandbox/fcp2/types.py 2008-02-26 18:54:12 UTC (rev 282)
@@ -235,8 +235,8 @@
class ConfigMessageParams(object):
"""Parameter --> FcpType mapping for config related messages"""
- ComponentSep = '.'
+
# all known config keys (param class stripped)
Params = {
@@ -370,7 +370,7 @@
@param paramName: (str) parameter name to split
@return: (list) components
"""
- return paramName.split(self.ComponentSep)
+ return paramName.split(consts.ConfigKeySep)
def splitParamClass(self, paramName):
@@ -378,7 +378,7 @@
@param paramName: (str) parameter name to split
@return: (tuple) paramClass, tail
"""
- result = paramName.split(self.ComponentSep, 1)
+ result = paramName.split(consts.ConfigKeySep, 1)
if len(result) == 2:
if result[0] in consts.ConfigValueClass.ClassesAll:
return result
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ju...@us...> - 2008-02-27 12:06:58
|
Revision: 290
http://fclient.svn.sourceforge.net/fclient/?rev=290&view=rev
Author: jurner
Date: 2008-02-27 04:06:59 -0800 (Wed, 27 Feb 2008)
Log Message:
-----------
combed over docs
Modified Paths:
--------------
trunk/sandbox/fcp2/types.py
Modified: trunk/sandbox/fcp2/types.py
===================================================================
--- trunk/sandbox/fcp2/types.py 2008-02-27 12:06:38 UTC (rev 289)
+++ trunk/sandbox/fcp2/types.py 2008-02-27 12:06:59 UTC (rev 290)
@@ -1,4 +1,4 @@
-"""Fcp types vs. Python types
+"""Fcp types vs Python types
This module handles type conversions from Fcp to Python and vice versa
"""
@@ -21,7 +21,6 @@
del hack
#<-- rel import hack
-
#*************************************************************************************
#
#*************************************************************************************
@@ -128,8 +127,10 @@
def fcpToPython(clss, value):
return int(value) / 1000
-#TODO: how to handle time deltas? Convert them to seconds?
-class FcpTypeTimeDelta(FcpType): pass
+class FcpTypeTimeDelta(FcpType):
+ """
+ @todo: how to handle time deltas? No idea...
+ """
class FcpTypeIP(FcpType): pass
class FcpTypeIPList(FcpType): pass
@@ -137,10 +138,10 @@
class FcpTypeStringList(FcpType): pass
class FcpTypeDirname(FcpType): pass
class FcpTypeFilename(FcpType): pass
-
-#TODO: how to handle byte amounts? Convert them to (int) bytes?
class FcpTypeNumBytes(FcpType):
- """Type conversion """
+ """
+ @todo: how to handle byte ammounts? No idea...
+ """
NamesBinary = ('', 'K', 'M', 'G', 'T', 'P', 'E')
NamesCommon = ('', 'k', 'm', 'g', 't', 'p', 'e')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ju...@us...> - 2008-02-29 16:26:00
|
Revision: 304
http://fclient.svn.sourceforge.net/fclient/?rev=304&view=rev
Author: jurner
Date: 2008-02-29 08:26:02 -0800 (Fri, 29 Feb 2008)
Log Message:
-----------
time deltas and byte amounts are converted now to python types
Modified Paths:
--------------
trunk/sandbox/fcp2/types.py
Modified: trunk/sandbox/fcp2/types.py
===================================================================
--- trunk/sandbox/fcp2/types.py 2008-02-29 16:25:42 UTC (rev 303)
+++ trunk/sandbox/fcp2/types.py 2008-02-29 16:26:02 UTC (rev 304)
@@ -5,6 +5,7 @@
import os, sys
import base64
+import re
#--> rel import hack
class _RelImportHack(object):
@@ -128,47 +129,85 @@
return int(value) / 1000
class FcpTypeTimeDelta(FcpType):
- """
- @todo: how to handle time deltas? No idea...
- """
+ """Time durations passed as tuple((int) number, modifier).
+
+ For modifiers see : L{consts.TimeDurationPostfix}. Number can be -1
+ aswell, meaniong 'not set' or 'undefined'.
+
+ >>> FcpTypeTimeDelta.fcpToPython('1000day')
+ (1000, 'day')
+
+ >>> FcpTypeTimeDelta.fcpToPython('arbitrary')
+ (-1, '')
+
+ >>> FcpTypeTimeDelta.pythonToFcp( (1000, 'day') )
+ '1000day'
+
+ """
+ NumberPattern = re.compile('''(\A \d+)''', re.X)
+
+ @classmethod
+ def pythonToFcp(clss, value):
+ return '%s%s' % value
+
+ @classmethod
+ def fcpToPython(clss, value):
+ value = value.lower()
+ result = clss.NumberPattern.split(value)
+ if len(result) == 3:
+ foo, foundInt, tail = result
+ if tail in consts.TimeDeltaPostfix.MembersAll:
+ num = int(foundInt)
+ return (num, tail)
+ return (-1, consts.TimeDeltaPostfix.Second)
+class FcpTypePercent(FcpTypeFloat): pass
+class FcpTypeUri(FcpType): pass
+
class FcpTypeIP(FcpType): pass
class FcpTypeIPList(FcpType): pass
class FcpTypeIPort(FcpType): pass
class FcpTypeStringList(FcpType): pass
class FcpTypeDirname(FcpType): pass
class FcpTypeFilename(FcpType): pass
-class FcpTypeNumBytes(FcpType):
+class FcpTypeByteAmount(FcpType):
+ """Byte amounts are passed as tuple((int, float) number, modifier).
+
+ For modifiers see : L{consts.ByteAmountPostfix}. Number of bytes can be -1
+ aswell, meaniong 'not set' or 'undefined'.
+
+ >>> FcpTypeByteAmount.fcpToPython('1000k')
+ (1000, 'k')
+
+ >>> FcpTypeByteAmount.fcpToPython('1.3k')
+ (1.3, 'k')
+
+ >>> FcpTypeByteAmount.fcpToPython('arbitrary')
+ (-1, '')
+
+ >>> FcpTypeByteAmount.pythonToFcp( (1000, 'k') )
+ '1000k'
+
"""
- @todo: how to handle byte ammounts? No idea...
- """
+ NumberPattern = re.compile('''(\A \d+ \. \d+) | (\A \d+)''', re.X)
- NamesBinary = ('', 'K', 'M', 'G', 'T', 'P', 'E')
- NamesCommon = ('', 'k', 'm', 'g', 't', 'p', 'e')
-
@classmethod
def pythonToFcp(clss, value):
- return format_num_bytes(value, binary=True, names=clss.NamesBinary)
+ return '%s%s' % value
@classmethod
def fcpToPython(clss, value):
- result = -1
- if value and value != '-1':
- if value[-1] in clss.NamesBinary:
- names = clss.NamesBinary
- binary = True
- else:
- names = clss.NamesCommon
- binary = False
- try:
- result = numbers.num_bytes_to_bytes(value, binary=binary, names=names)
- except ValueError:
- pass
- return result
-
-
-
-
+ result = clss.NumberPattern.split(value)
+ if len(result) == 4:
+ foo, foundFloat, foundInt, tail = result
+ if tail in consts.ByteAmountPostfix.MembersAll:
+ if foundFloat:
+ num = float(foundFloat)
+ else:
+ num = int(foundInt)
+ return (num, tail)
+ return (-1, consts.ByteAmountPostfix.Bytes)
+
class FcpTypePercent(FcpTypeFloat): pass
class FcpTypeUri(FcpType): pass
@@ -276,9 +315,9 @@
'logger.dirname': FcpTypeDirname,
'logger.enabled': FcpTypeBool,
'logger.interval': FcpTypeTimeDelta,
- 'logger.maxCachedBytes': FcpTypeNumBytes,
- 'logger.maxCachedLines': FcpTypeNumBytes, # ???
- 'logger.maxZippedLogsSize': FcpTypeNumBytes, # ???
+ 'logger.maxCachedBytes': FcpTypeByteAmount,
+ 'logger.maxCachedLines': FcpTypeByteAmount, # ???
+ 'logger.maxZippedLogsSize': FcpTypeByteAmount, # ???
'logger.priority': FcpTypeChoiceLoggerPriority,
'logger.priorityDetail': FcpType, # ???? is it Detailed priority thresholds ???
@@ -286,7 +325,7 @@
'node.assumeNATed': FcpTypeBool,
'node.bindTo': FcpTypeIP,
'node.clientThrottleFile': FcpTypeFilename,
- 'node.databaseMaxMemory': FcpTypeNumBytes,
+ 'node.databaseMaxMemory': FcpTypeByteAmount,
'node.disableHangCheckers': FcpTypeBool,
'node.disableProbabilisticHTLs': FcpTypeBool,
'node.downloadAllowedDirs': FcpTypeChoiceNodeDownloadAllowedDirs,
@@ -299,7 +338,7 @@
'node.enableULPRDataPropagation': FcpTypeBool,
'node.extraPeerDataDir': FcpTypeDirname,
'node.includeLocalAddressesInNoderefs': FcpTypeBool,
- 'node.inputBandwidthLimit': FcpTypeNumBytes, # -1 is possible as value aswell
+ 'node.inputBandwidthLimit': FcpTypeByteAmount, # -1 is possible as value aswell
'node.ipAddressOverride': FcpTypeIP,
'node.l10n': FcpType, # ???
'node.lazyResume': FcpTypeBool,
@@ -309,12 +348,12 @@
'node.name': FcpTypeString,
'node.nodeDir': FcpTypeDirname,
'node.oneConnectionPerIP': FcpTypeBool,
- 'node.outputBandwidthLimit': FcpTypeNumBytes,
+ 'node.outputBandwidthLimit': FcpTypeByteAmount,
'node.passOpennetPeersThroughDarknet': FcpTypeBool,
'node.persistentTempDir': FcpTypeDirname,
'node.storeDir': FcpTypeDirname,
'node.storeForceBigShrinks': FcpTypeBool,
- 'node.storeSize': FcpTypeNumBytes,
+ 'node.storeSize': FcpTypeByteAmount,
'node.storeType': FcpTypeString,
'node.tempDir': FcpTypeDirname,
'node.tempIPAddressHint': FcpTypeIP, # ???
@@ -324,7 +363,7 @@
'node.testnet.enabled': FcpTypeBool,
'node.load.aggressiveGC': FcpType, # ???
- 'node.load.freeHeapBytesThreshold': FcpTypeNumBytes,
+ 'node.load.freeHeapBytesThreshold': FcpTypeByteAmount,
'node.load.freeHeapPercentThreshold': FcpTypePercent,
'node.load.memoryChecker': FcpTypeBool,
'node.load.nodeThrottleFile': FcpTypeFilename,
@@ -762,5 +801,10 @@
MessageParamTypes['Peer'] = MessageParamTypes['AddPeer'] = PeerMessageParams
+#********************************************************************************************
+#
+#********************************************************************************************
+if __name__ == '__main__':
+ import doctest
+ doctest.testmod()
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ju...@us...> - 2008-03-06 11:59:28
|
Revision: 313
http://fclient.svn.sourceforge.net/fclient/?rev=313&view=rev
Author: jurner
Date: 2008-03-06 03:59:34 -0800 (Thu, 06 Mar 2008)
Log Message:
-----------
some more type conversions
Modified Paths:
--------------
trunk/sandbox/fcp2/types.py
Modified: trunk/sandbox/fcp2/types.py
===================================================================
--- trunk/sandbox/fcp2/types.py 2008-03-06 11:59:02 UTC (rev 312)
+++ trunk/sandbox/fcp2/types.py 2008-03-06 11:59:34 UTC (rev 313)
@@ -652,6 +652,7 @@
},
'ClientPut': {
'BinaryBlob': FcpTypeBool,
+ 'DataLength': FcpTypeInt,
'DontCompress': FcpTypeBool,
'EarlyEncode': FcpTypeBool,
'GetCHKOnly': FcpTypeBool,
@@ -659,6 +660,9 @@
'MaxRetries': FcpTypeInt,
'Verbosity': FcpTypeInt,
},
+ 'FCPPluginReply': {
+ 'DataLength': FcpTypeInt,
+ },
'GetConfig': {
'WithCurrent': FcpTypeBool,
'WithDefaults': FcpTypeBool,
@@ -719,6 +723,7 @@
#
'AllData': {
'Global': FcpTypeBool,
+ 'DataLength': FcpTypeInt,
#NOTE: we ignore startup and completion time here as long as it is not passed in all related messages
},
#'ConfigData': # added later as ConfigMessageParams()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-03-08 11:05:57
|
Revision: 336
http://fclient.svn.sourceforge.net/fclient/?rev=336&view=rev
Author: jUrner
Date: 2008-03-08 03:05:30 -0800 (Sat, 08 Mar 2008)
Log Message:
-----------
moved all message related stuff to message.py
Modified Paths:
--------------
trunk/sandbox/fcp2/types.py
Modified: trunk/sandbox/fcp2/types.py
===================================================================
--- trunk/sandbox/fcp2/types.py 2008-03-08 11:05:00 UTC (rev 335)
+++ trunk/sandbox/fcp2/types.py 2008-03-08 11:05:30 UTC (rev 336)
@@ -263,549 +263,6 @@
ChoicesAll = (Stl, SslV3, TlsV1)
ChoicesAllowMultiple = False
-
-#***************************************************************************************
-#
-# param types for config message
-#
-# ..bit more efford here, cos we need types for user input checking
-# ...a slpoppy implementation of a dict should be enough
-#
-#***************************************************************************************
-class ConfigMessageParams(object):
- """Parameter --> FcpType mapping for config related messages"""
-
-
-
- # all known config keys (param class stripped)
- Params = {
-
- 'console.allowedHosts': FcpTypeIPList, # host names, single IPs CIDR-maskip IPs likee 192.168.0.0/24
- 'console.bindTo': FcpTypeIPList,
- 'console.directEnabled': FcpTypeBool,
- 'console.enabled': FcpTypeBool,
- 'console.port': FcpTypeIPort,
- 'console.ssl': FcpTypeBool,
-
- 'fcp.allowedHosts': FcpTypeIPList,
- 'fcp.allowedHostsFullAccess': FcpTypeIPList,
- 'fcp.assumeDownloadDDAIsAllowed': FcpTypeBool,
- 'fcp.assumeUploadDDAIsAllowed': FcpTypeBool,
- 'fcp.bindTo': FcpTypeIP,
- 'fcp.enabled': FcpTypeBool,
- 'fcp.persistentDownloadsEnabled': FcpTypeBool,
- 'fcp.persistentDownloadsFile': FcpTypeFilename,
- 'fcp.persistentDownloadsInterval': FcpTypeTimeDelta,
- 'fcp.port': FcpTypeIPort,
- 'fcp.ssl': FcpTypeBool,
-
- 'fproxy.CSSOverride': FcpTypeBool,
- 'fproxy.advancedModeEnabled': FcpTypeBool,
- 'fproxy.allowedHosts': FcpTypeIPList,
- 'fproxy.allowedHostsFullAccess': FcpTypeIPList,
- 'fproxy.bindTo': FcpTypeIPList,
- 'fproxy.css': FcpTypeChoiceFProxyCss,
- 'fproxy.doRobots': FcpTypeBool,
- 'fproxy.enabled': FcpTypeBool,
- 'fproxy.javascriptEnabled': FcpTypeBool,
- 'fproxy.port': FcpTypeIPort,
- 'fproxy.showPanicButton': FcpTypeBool,
- 'fproxy.ssl': FcpTypeBool,
-
- 'logger.dirname': FcpTypeDirname,
- 'logger.enabled': FcpTypeBool,
- 'logger.interval': FcpTypeTimeDelta,
- 'logger.maxCachedBytes': FcpTypeByteAmount,
- 'logger.maxCachedLines': FcpTypeByteAmount, # ???
- 'logger.maxZippedLogsSize': FcpTypeByteAmount, # ???
- 'logger.priority': FcpTypeChoiceLoggerPriority,
- 'logger.priorityDetail': FcpType, # ???? is it Detailed priority thresholds ???
-
- 'node.alwaysAllowLocalAddresses': FcpTypeBool,
- 'node.assumeNATed': FcpTypeBool,
- 'node.bindTo': FcpTypeIP,
- 'node.clientThrottleFile': FcpTypeFilename,
- 'node.databaseMaxMemory': FcpTypeByteAmount,
- 'node.disableHangCheckers': FcpTypeBool,
- 'node.disableProbabilisticHTLs': FcpTypeBool,
- 'node.downloadAllowedDirs': FcpTypeChoiceNodeDownloadAllowedDirs,
- 'node.downloadsDir': FcpTypeDirname,
- 'node.enableARKs': FcpTypeBool,
- 'node.enablePacketCoalescing': FcpTypeBool,
- 'node.enablePerNodeFailureTables': FcpTypeBool,
- 'node.enableSwapping': FcpTypeBool,
- 'node.enableSwapQueueing': FcpTypeBool,
- 'node.enableULPRDataPropagation': FcpTypeBool,
- 'node.extraPeerDataDir': FcpTypeDirname,
- 'node.includeLocalAddressesInNoderefs': FcpTypeBool,
- 'node.inputBandwidthLimit': FcpTypeByteAmount, # -1 is possible as value aswell
- 'node.ipAddressOverride': FcpTypeIP,
- 'node.l10n': FcpType, # ???
- 'node.lazyResume': FcpTypeBool,
- 'node.listenPort': FcpTypeIPort,
- 'node.maxBackgroundUSKFetchers': FcpTypeIntWithBounds(0, None),
- 'node.maxHTL': FcpTypeIntWithBounds(0, None),
- 'node.name': FcpTypeString,
- 'node.nodeDir': FcpTypeDirname,
- 'node.oneConnectionPerIP': FcpTypeBool,
- 'node.outputBandwidthLimit': FcpTypeByteAmount,
- 'node.passOpennetPeersThroughDarknet': FcpTypeBool,
- 'node.persistentTempDir': FcpTypeDirname,
- 'node.storeDir': FcpTypeDirname,
- 'node.storeForceBigShrinks': FcpTypeBool,
- 'node.storeSize': FcpTypeByteAmount,
- 'node.storeType': FcpTypeString,
- 'node.tempDir': FcpTypeDirname,
- 'node.tempIPAddressHint': FcpTypeIP, # ???
- 'node.testingDropPacketsEvery': FcpTypeIntWithBounds(0, None),
- 'node.uploadAllowedDirs': FcpTypeChoiceNodeDownloadAllowedDirs,
-
- 'node.testnet.enabled': FcpTypeBool,
-
- 'node.load.aggressiveGC': FcpType, # ???
- 'node.load.freeHeapBytesThreshold': FcpTypeByteAmount,
- 'node.load.freeHeapPercentThreshold': FcpTypePercent,
- 'node.load.memoryChecker': FcpTypeBool,
- 'node.load.nodeThrottleFile': FcpTypeFilename,
- 'node.load.threadLimit': FcpTypeIntWithBounds(0, None),
-
- 'node.opennet.acceptSeedConnections': FcpTypeBool,
- 'node.opennet.alwaysAllowLocalAddresses': FcpTypeBool,
- 'node.opennet.assumeNATed': FcpTypeBool,
- 'node.opennet.bindTo': FcpTypeIP,
- 'node.opennet.enabled': FcpTypeBool,
- 'node.opennet.listenPort': FcpTypeIPort,
- 'node.opennet.maxOpennetPeers': FcpTypeIntWithBounds(0, None),
- 'node.opennet.oneConnectionPerIP': FcpTypeBool,
- 'node.opennet.testingDropPacketsEvery': FcpTypeIntWithBounds(0, None),
-
- 'node.scheduler.CHKinserter_priority_policy': FcpTypeChoicePriorityPolicy,
- 'node.scheduler.CHKrequester_priority_policy': FcpTypeChoicePriorityPolicy,
- 'node.scheduler.SSKinserter_priority_policy': FcpTypeChoicePriorityPolicy,
- 'node.scheduler.SSKrequester_priority_policy': FcpTypeChoicePriorityPolicy,
-
- 'node.updater.URI': FcpTypeUri,
- 'node.updater.autoupdate': FcpTypeBool,
- 'node.updater.enabled': FcpTypeBool,
- 'node.updater.extURI': FcpTypeUri,
- 'node.updater.revocationURI': FcpTypeUri,
-
- 'pluginmanager.loadplugin': FcpTypeStringList,
- 'pluginmanager2.loadedPlugins': FcpTypeStringList,
-
- 'ssl.sslEnable': FcpTypeBool,
- 'ssl.sslKeyPass': FcpTypeString,
- 'ssl.sslKeyStore': FcpTypeFilename,
- 'ssl.sslKeyStorePass': FcpTypeString,
- 'ssl.sslVersion': FcpTypeChoiceSSLVersion,
-
- 'toadletsymlinker.symlinks': FcpTypeStringList,
- }
-
- def __init__(self):
- pass
-
- def splitAll(self, paramName):
- """Splits a parameter name into its components
- @param paramName: (str) parameter name to split
- @return: (list) components
- """
- return paramName.split(consts.ConfigKeySep)
-
-
- def splitParamClass(self, paramName):
- """Splits the parameter class from a parameter name
- @param paramName: (str) parameter name to split
- @return: (tuple) paramClass, tail
- """
- result = paramName.split(consts.ConfigKeySep, 1)
- if len(result) == 2:
- if result[0] in consts.ConfigValueClass.ClassesAll:
- return result
- return '', paramName
-
-
- def get(self, paramName, default=None):
- """Returns the type of a parameter or default
- @param paramName: (str) name of the parameter to retuen the type for
- @return: (FcpType)
- """
- try:
- return self[paramName]
- except KeyError:
- return default
-
-
- def __getitem__(self, paramName):
- """Returns the type of a parameter
- @param paramName: (str) name of the parameter to retuen the type for
- @return: (FcpType)
- """
- paramClass, paramKey = self.splitParamClass(paramName)
- if paramClass == consts.ConfigValueClass.Current or paramClass == '':
- return self.Params[paramKey]
- elif paramClass == consts.ConfigValueClass.Default:
- return self.Params[paramKey]
- elif paramClass == consts.ConfigValueClass.ExpertFlag:
- return FcpTypeBool
- elif paramClass == consts.ConfigValueClass.ForceWriteFlag:
- return FcpTypeBool
- elif paramClass == consts.ConfigValueClass.ShortDescription:
- return FcpTypeString
- elif paramClass == consts.ConfigValueClass.LongDescription:
- return FcpTypeString
- elif paramClass == consts.ConfigValueClass.SortOrder:
- return FcpTypeInt
- elif paramClass == consts.ConfigValueClass.DataType:
- return FcpTypeString
- else:
- raise ValueError('Unknown param class in: %r' % paramName)
-
-#***************************************************************************************
-#
-# param types for peer message
-#
-# ..need to do a bit more here, cos it may be needed to validate user input
-#
-#***************************************************************************************
-PeerMessageParams = {
- 'ark.number': FcpTypeInt,
- 'auth.negTypes': FcpTypeInt,
-
- 'location': FcpTypeFloat,
- 'opennet': FcpTypeBool,
- 'testnet': FcpTypeBool,
-
- 'metadata.timeLastConnected': FcpTypeTime,
- 'metadata.timeLastReceivedPacket': FcpTypeTime,
- 'metadata.timeLastRoutable': FcpTypeTime,
- 'metadata.timeLastSuccess': FcpTypeTime,
- 'metadata.routableConnectionCheckCount': FcpTypeInt,
- 'metadata.hadRoutableConnectionCount': FcpTypeInt,
-
- 'volatile.averagePingTime': FcpTypeFloat,
- 'volatile.overloadProbability': FcpTypePercent,
- 'volatile.routingBackoff': FcpTypeInt,
- 'volatile.routingBackoffPercent': FcpTypePercent,
- 'volatile.totalBytesIn': FcpTypeInt,
- 'volatile.totalBytesOut': FcpTypeInt,
- 'volatile.routingBackoffLength': FcpTypeInt,
- }
-
-'''all other Peer message params here....
-
->> identity=YIrE..................
->> lastGoodVersion=Fred,0.7,1.0,1106
->> physical.udp=00.000.000.000:00000
->> version=Fred,0.7,1.0,1107
->> dsaGroup.q=ALFDN...............
->> dsaGroup.p=AIYIrE..................
->> dsaPubKey.y=YSlb............
->> dsaGroup.g=UaRa...............
->> ark.pubURI=SSK@......................
->>
->> metadata.detected.udp=000.000.000.000:00000
-
->> volatile.lastRoutingBackoffReason=ForwardRejectedOverload
->> volatile.percentTimeRoutableConnection=99.4735.................
->> volatile.status=CONNECTED
-
-'''
-
-#***************************************************************************************
-#
-# param types for node message
-#
-#***************************************************************************************
-NodeMessageParams = {
- 'ark.number': FcpTypeInt,
- 'auth.negTypes': FcpTypeInt,
- 'location': FcpTypeFloat,
- 'opennet': FcpTypeBool,
- 'testnet': FcpTypeBool,
-
- 'volatile.allocatedJavaMemory': FcpTypeInt,
- 'volatile.availableCPUs': FcpTypeInt,
- 'volatile.averagePingTime': FcpTypeFloat,
- 'volatile.avgStoreAccessRate': FcpTypePercent,
- 'volatile.backedOffPercent': FcpTypePercent,
- 'volatile.bwlimitDelayTime': FcpTypeFloat,
- 'volatile.cacheAccess': FcpTypeInt,
- 'volatile.cachedKeys': FcpTypeInt,
- 'volatile.cachedSize': FcpTypeInt,
- 'volatile.cachedStoreHits': FcpTypeInt,
- 'volatile.cachedStoreMisses': FcpTypeInt,
- 'volatile.freeJavaMemory': FcpTypeInt,
- 'volatile.isUsingWrapper': FcpTypeBool,
- 'volatile.locationChangePerMinute': FcpTypeFloat,
- 'volatile.locationChangePerSession': FcpTypeFloat,
- 'volatile.locationChangePerSwap': FcpTypeFloat,
- 'volatile.maximumJavaMemory': FcpTypeInt,
- 'volatile.maxOverallKeys': FcpTypeInt,
- 'volatile.maxOverallSize': FcpTypeInt,
- 'volatile.networkSizeEstimate24hourRecent': FcpTypeInt,
- 'volatile.networkSizeEstimate48hourRecent': FcpTypeInt,
- 'volatile.networkSizeEstimateSession': FcpTypeInt,
- 'volatile.noSwaps': FcpTypeFloat,
- 'volatile.noSwapsPerMinute': FcpTypeFloat,
- 'volatile.numberOfARKFetchers': FcpTypeInt,
- 'volatile.numberOfBursting': FcpTypeInt,
- 'volatile.numberOfConnected': FcpTypeInt,
- 'volatile.numberOfDisabled': FcpTypeInt,
- 'volatile.numberOfDisconnected': FcpTypeInt,
- 'volatile.numberOfInsertSenders': FcpTypeInt,
- 'volatile.numberOfListening': FcpTypeInt,
- 'volatile.numberOfListenOnly': FcpTypeInt,
- 'volatile.numberOfNeverConnected': FcpTypeInt,
- 'volatile.numberOfNotConnected': FcpTypeInt,
- 'volatile.numberOfRemotePeerLocationsSeenInSwaps': FcpTypeFloat,
- 'volatile.numberOfRequestSenders': FcpTypeInt,
- 'volatile.numberOfRoutingBackedOff': FcpTypeInt,
- 'volatile.numberOfSimpleConnected': FcpTypeInt,
- 'volatile.numberOfTooNew': FcpTypeInt,
- 'volatile.numberOfTooOld': FcpTypeInt,
- 'volatile.numberOfTransferringRequestSenders': FcpTypeInt,
- 'volatile.numberWithRoutingBackoffReasons.ForwardRejectedOverload': FcpTypeInt,
- 'volatile.overallAccesses': FcpTypeInt,
- 'volatile.overallKeys': FcpTypeInt,
- 'volatile.overallSize': FcpTypeInt,
- 'volatile.percentCachedStoreHitsOfAccesses': FcpTypePercent,
- 'volatile.percentOverallKeysOfMax': FcpTypePercent,
- 'volatile.percentStoreHitsOfAccesses': FcpTypePercent,
- 'volatile.pInstantReject': FcpTypeFloat, # or percent?
- 'volatile.recentInputRate': FcpTypeFloat,
- 'volatile.recentOutputRate': FcpTypeFloat,
- 'volatile.routingMissDistance': FcpTypeFloat,
- 'volatile.runningThreadCount': FcpTypeInt,
- 'volatile.startedSwaps': FcpTypeInt,
- 'volatile.startupTime': FcpTypeTime,
- 'volatile.storeAccesses': FcpTypeInt,
- 'volatile.storeHits': FcpTypeInt,
- 'volatile.storeKeys': FcpTypeInt,
- 'volatile.storeMisses': FcpTypeInt,
- 'volatile.storeSize': FcpTypeInt,
- 'volatile.swaps': FcpTypeFloat,
- 'volatile.swapsPerMinute': FcpTypeFloat,
- 'volatile.swapsPerNoSwaps': FcpTypeFloat,
- 'volatile.swapsRejectedAlreadyLocked': FcpTypeInt,
- 'volatile.swapsRejectedLoop': FcpTypeInt,
- 'volatile.swapsRejectedNowhereToGo': FcpTypeInt,
- 'volatile.swapsRejectedRateLimit': FcpTypeInt,
- 'volatile.swapsRejectedRecognizedID': FcpTypeInt,
- 'volatile.totalInputBytes': FcpTypeInt,
- 'volatile.totalInputRate': FcpTypeInt,
- 'volatile.totalOutputBytes': FcpTypeInt,
- 'volatile.totalOutputRate': FcpTypeInt,
- 'volatile.totalPayloadOutputBytes': FcpTypeInt,
- 'volatile.totalPayloadOutputPercent': FcpTypePercent,
- 'volatile.totalPayloadOutputRate': FcpTypeInt,
- 'volatile.unclaimedFIFOSize': FcpTypeInt,
- 'volatile.uptimeSeconds': FcpTypeInt,
- 'volatile.usedJavaMemory': FcpTypeInt,
- }
-
-
-'''
->>all other NodeData message params here....
->>
->> physical.udp=000.000.000.000:00000
->> dsaPubKey.y=GarpsNUKe.................................................
->> version=Fred,0.7,1.0,1107
->> myName=whatever
->> ark.pubURI=SSK@...............
-
->> dsaGroup.q=ALFDNoq.....
->> dsaGroup.p=AIYIrE9VNhM3.............
->> volatile.avgConnectedPeersPerNode=00.00................
->> dsaGroup.g=UaRa.............
->> dsaPrivKey.x=Pwam..................
->> ark.privURI=SSK@.................
->> lastGoodVersion=Fred,0.7,1.0,1106
->> sig=691f............
->> identity=vMQa~..................
-
-'''
-#***************************************************************************************
-#
-# Mapping from message params to param types
-#
-# ...being lazy here, only types that are not strings are declared
-#
-#***************************************************************************************
-MessageParamTypes = {
-
- # client messages
- #
- #'AddPeer': # added later as PeerMessageParams
- 'ClientGet': {
- 'BinaryBlob': FcpTypeBool,
- 'Global': FcpTypeBool,
- 'IgnoreDS': FcpTypeBool,
- 'DSOnly': FcpTypeBool,
- 'MaxRetries': FcpTypeInt,
- 'MaxSize': FcpTypeInt,
- 'MaxTempSize': FcpTypeInt,
- 'Verbosity': FcpTypeInt,
- },
- 'ClientHello': {
- 'ExpectedVersion': FcpTypeFloat,
- },
- 'ClientPut': {
- 'BinaryBlob': FcpTypeBool,
- 'DataLength': FcpTypeInt,
- 'DontCompress': FcpTypeBool,
- 'EarlyEncode': FcpTypeBool,
- 'GetCHKOnly': FcpTypeBool,
- 'Global': FcpTypeBool,
- 'MaxRetries': FcpTypeInt,
- 'Verbosity': FcpTypeInt,
- },
- 'FCPPluginReply': {
- 'DataLength': FcpTypeInt,
- },
- 'GetConfig': {
- 'WithCurrent': FcpTypeBool,
- 'WithDefaults': FcpTypeBool,
- 'WithSortOrder': FcpTypeBool,
- 'WithExpertFlag': FcpTypeBool,
- 'WithForceWriteFlag': FcpTypeBool,
- 'WithShortDescription': FcpTypeBool,
- 'WithLongDescription': FcpTypeBool,
- },
- 'GetNode': {
- 'GiveOpennetRef': FcpTypeBool,
- 'WithPrivate': FcpTypeBool,
- 'WithVolatile': FcpTypeBool,
- },
- 'GetPluginInfo': {
- 'Detailed': FcpTypeBool,
- },
- 'GetRequestStatus': {
- 'Global': FcpTypeBool,
- 'OnlyData': FcpTypeBool,
- },
- 'ListPeer': {
- 'WithMetadata': FcpTypeBool,
- 'WithVolantile': FcpTypeBool,
- },
- 'ListPeers': {
- 'WithMetadata': FcpTypeBool,
- 'WithVolantile': FcpTypeBool,
- },
- 'ModifyPeer': {
- 'AllowLocalAddresses': FcpTypeBool,
- 'IsDisabled': FcpTypeBool,
- 'ListenOnly': FcpTypeBool,
- },
- #'ModifyConfig': # added later as ConfigMessageParams()
- 'ModifyPeerNote': {
- 'NoteText': FcpTypeBase64EncodedString,
- },
- 'ModifyPersistentRequest': {
- 'Global': FcpTypeBool,
- },
- 'RemopvePersistentRequest': {
- 'Global': FcpTypeBool,
- },
- 'SubscribeUSK': {
- 'DontPoll': FcpTypeBool,
- },
- 'TestDDARequest': {
- 'WantReadDirectory': FcpTypeBool,
- 'WantWriteDirectory': FcpTypeBool,
- },
- 'WatchGlobal': {
- 'Enabled': FcpTypeBool,
- 'VerbosityMask': FcpTypeInt,
- },
-
- # node messages
- #
- 'AllData': {
- 'Global': FcpTypeBool,
- 'DataLength': FcpTypeInt,
- #NOTE: we ignore startup and completion time here as long as it is not passed in all related messages
- },
- #'ConfigData': # added later as ConfigMessageParams()
- 'DataFound': {
- 'Global': FcpTypeBool,
- 'DataLength': FcpTypeInt,
- },
- 'FinishedCompression': {
- 'OriginalSize': FcpTypeInt,
- 'CompressedSize': FcpTypeInt,
- },
- 'GetFailed': {
- 'Code': FcpTypeInt,
- 'ExpectedDataLength': FcpTypeInt_GetFailed_ExpectedDataLenght,
- 'Fatal': FcpTypeBool,
- 'FinalizedExpected': FcpTypeBool,
- 'Global': FcpTypeBool,
- },
- 'GetPluginInfo': {
- 'Started': FcpTypeBool,
- },
- 'IdentifierCollision': {
- 'Global': FcpTypeBool,
- },
- #'NodeData': # added later as NodeMessageParams
- 'NodeHello': {
- 'Build': FcpTypeInt,
- 'CompressionCodecs': FcpTypeInt,
- 'ExtBuild': FcpTypeInt,
- #'ExtRevision': FcpTypeInt,
- 'FcpVersion': FcpTypeFloat,
- 'Testnet': FcpTypeBool,
- },
- #'Peer': # added later as PeerMessageParams
- 'PeerNote': {
- 'NoteText': FcpTypeBase64EncodedString,
- },
- 'PersistentRequestModified': {
- 'Global': FcpTypeBool,
- },
- 'PersistentRequestRemoved': {
- 'Global': FcpTypeBool,
- },
- 'ProtocolError': {
- 'Code': FcpTypeInt,
- 'Global': FcpTypeBool,
- },
- 'PutFailed': {
- 'Global': FcpTypeBool,
- 'Code': FcpTypeInt,
- },
- 'PutFetchable': {
- 'Global': FcpTypeBool,
- },
- 'SimpleProgress': {
- 'Total': FcpTypeInt,
- 'Required': FcpTypeInt,
- 'Failed': FcpTypeInt,
- 'FatalyFailed': FcpTypeInt,
- 'Succeeded': FcpTypeInt,
- 'FinalizedTotal': FcpTypeBool,
- },
- 'SubscribedUSKUpdate': {
- 'Edition': FcpTypeInt,
- },
- 'TestDDAComplete': {
- 'ReadDirectoryAllowed': FcpTypeBool,
- 'WriteDirectoryAllowed': FcpTypeBool,
- },
- }
-
-MessageParamTypes['ClientPutDiskDir'] = MessageParamTypes['ClientPut']
-MessageParamTypes['ClientComplexDir'] = MessageParamTypes['ClientPut']
-
-# TODO: "Started" param? Think we simply ignore it
-MessageParamTypes['PersistentGet'] = MessageParamTypes['ClientGet']
-MessageParamTypes['PersistentPut'] = MessageParamTypes['ClientPut']
-
-MessageParamTypes['ModifyConfig'] = MessageParamTypes['ConfigData'] = ConfigMessageParams()
-MessageParamTypes['Peer'] = MessageParamTypes['AddPeer'] = PeerMessageParams
-
-
#********************************************************************************************
#
#********************************************************************************************
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-04-08 10:10:35
|
Revision: 374
http://fclient.svn.sourceforge.net/fclient/?rev=374&view=rev
Author: jUrner
Date: 2008-04-08 03:10:08 -0700 (Tue, 08 Apr 2008)
Log Message:
-----------
superfluous import
Modified Paths:
--------------
trunk/sandbox/fcp2/types.py
Modified: trunk/sandbox/fcp2/types.py
===================================================================
--- trunk/sandbox/fcp2/types.py 2008-04-08 10:08:08 UTC (rev 373)
+++ trunk/sandbox/fcp2/types.py 2008-04-08 10:10:08 UTC (rev 374)
@@ -17,7 +17,6 @@
hack =_RelImportHack(2)
from fcp2 import consts
-from fcp2.fcp_lib import numbers
del hack
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-04-09 22:33:52
|
Revision: 398
http://fclient.svn.sourceforge.net/fclient/?rev=398&view=rev
Author: jUrner
Date: 2008-04-09 14:46:27 -0700 (Wed, 09 Apr 2008)
Log Message:
-----------
fixed docs
Modified Paths:
--------------
trunk/sandbox/fcp2/types.py
Modified: trunk/sandbox/fcp2/types.py
===================================================================
--- trunk/sandbox/fcp2/types.py 2008-04-09 21:46:20 UTC (rev 397)
+++ trunk/sandbox/fcp2/types.py 2008-04-09 21:46:27 UTC (rev 398)
@@ -130,7 +130,7 @@
class FcpTypeTimeDelta(FcpType):
"""Time durations passed as tuple((int) number, modifier).
- For modifiers see : L{consts.TimeDurationPostfix}. Number can be -1
+ For modifiers see : L{consts.TimeDeltaPostfix}. Number can be -1
aswell, meaniong 'not set' or 'undefined'.
>>> FcpTypeTimeDelta.fcpToPython('1000day')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|