Thread: SF.net SVN: fclient: [102] trunk/sandbox/fcp/fcp2_0_types.py
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <ju...@us...> - 2008-02-02 05:10:54
|
Revision: 102
http://fclient.svn.sourceforge.net/fclient/?rev=102&view=rev
Author: jurner
Date: 2008-02-01 21:11:00 -0800 (Fri, 01 Feb 2008)
Log Message:
-----------
added types module
Added Paths:
-----------
trunk/sandbox/fcp/fcp2_0_types.py
Added: trunk/sandbox/fcp/fcp2_0_types.py
===================================================================
--- trunk/sandbox/fcp/fcp2_0_types.py (rev 0)
+++ trunk/sandbox/fcp/fcp2_0_types.py 2008-02-02 05:11:00 UTC (rev 102)
@@ -0,0 +1,738 @@
+"""Fcp types vs. Python types
+
+This module handles type conversions from Fcp to Python and vice versa
+"""
+
+import base64
+
+import fcp2_0_consts as consts
+#*************************************************************************************
+#
+#*************************************************************************************
+class FcpType(object):
+
+ @classmethod
+ def pythonToFcp(clss, value):
+ return value
+
+ @classmethod
+ def fcpToPython(clss, value):
+ return value
+
+
+class FcpTypeString(FcpType):
+
+ @classmethod
+ def pythonToFcp(clss, value):
+ return str(value) #TODO: unicode ???
+
+ @classmethod
+ def fcpToPython(clss, value):
+ return value
+
+
+class FcpTypeBool(FcpType):
+
+ @classmethod
+ def pythonToFcp(clss, value):
+ return consts.FcpTrue if value else consts.FcpFalse
+
+ @classmethod
+ def fcpToPython(clss, value):
+ return value == consts.FcpTrue
+
+
+class FcpTypeInt(FcpType):
+
+ @classmethod
+ def pythonToFcp(clss, value):
+ return str(value)
+
+ @classmethod
+ def fcpToPython(clss, value):
+ return int(value)
+
+
+class FcpTypeFloat(FcpType):
+
+ @classmethod
+ def pythonToFcp(clss, value):
+ return str(value)
+
+ @classmethod
+ def fcpToPython(clss, value):
+ return float(value)
+
+
+# GetFailed sets the ExpectedDataLenght field to '' (empty string). Fix this to show up as -1
+class FcpTypeInt_GetFailed_ExpectedDataLenght(FcpType):
+
+ @classmethod
+ def pythonToFcp(clss, value):
+ return str(value)
+
+ @classmethod
+ def fcpToPython(clss, value):
+ if value == '':
+ return -1
+ return int(value)
+
+
+class FcpTypeIntWithBounds(FcpType):
+
+ def __init__(self, lowerBound, upperBound):
+ self.lowerBound = lowerBound
+ self.upperBound = upperBound
+
+ def pythonToFcp(self, value):
+ return str(value)
+
+ def fcpToPython(self, value):
+ return int(value)
+
+
+class FcpTypeBase64EncodedString(FcpType):
+
+ @classmethod
+ def pythonToFcp(clss, value):
+ return base64.b64encode(value)
+
+ @classmethod
+ def fcpToPython(clss, value):
+ return base64.b64decode(value)
+
+
+class FcpTypeTime(FcpType):
+
+ @classmethod
+ def pythonToFcp(clss, value):
+ return str(value * 1000)
+
+ @classmethod
+ def fcpToPython(clss, value):
+ return int(value) / 1000
+
+
+
+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): pass
+class FcpTypePercent(FcpTypeFloat): pass
+class FcpTypeUri(FcpType): pass
+
+
+# special choice types for config message
+
+
+class FcpTypeChoiceFProxyCss(FcpType):
+ Clean = 'Clean'
+ Boxed = 'boxed'
+ GrayAndBlue = 'grayandblue'
+ Sky = 'sky'
+
+ ChoicesAll = (Clean, Boxed, GrayAndBlue, Sky)
+ ChoicesAllowMultiple = False
+
+class FcpTypeChoiceLoggerPriority(FcpType):
+ Error = 'ERROR'
+ Normal = 'NORMAL'
+ Minor = 'MINOR'
+ Debug = 'DEBUG'
+
+ ChoicesAll = (Error, Normal, Minor, Debug)
+ ChoicesAllowMultiple = False
+
+class FcpTypeChoiceNodeDownloadAllowedDirs(FcpType):
+ All = 'all'
+ Downloads = 'downloads'
+ Nowhere = ''
+
+ ChoicesAll = (All, Downloads, Nowhere)
+ ChoicesAllowMultiple = False
+
+class FcpTypeChoiceNodeUploadAllowedDirs(FcpType):
+ All = 'all'
+ Nowhere = ''
+ ChoicesAll = (All, Nowhere)
+ ChoicesAllowMultiple = False
+
+class FcpTypeChoicePriorityPolicy(FcpType):
+ Hard = 'HARD'
+ Soft = 'SOFT'
+
+ ChoicesAll = (Hard, Soft)
+ ChoicesAllowMultiple = False
+
+
+class FcpTypeChoiceSSLVersion(FcpType):
+ Stl = 'STL'
+ SslV3 = 'SSLV3'
+ TlsV1 = 'TLSv1'
+
+ 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):
+
+ ComponentsSep = '.'
+
+
+ # 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,
+ )
+
+
+
+ # 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': FcpTypeIntWithBounds(0, None),
+ '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': FcpType, # ??? 1HOUR ??
+ 'logger.maxCachedBytes': FcpTypeNumBytes,
+ 'logger.maxCachedLines': FcpTypeNumBytes, # ???
+ 'logger.maxZippedLogsSize': FcpTypeNumBytes, # ???
+ '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': FcpTypeNumBytes,
+ 'node.disableHangCheckers': FcpTypeBool,
+ 'node.disableProbabilisticHTLs': FcpTypeBool,
+ 'node.downloadAllowedDirs': FcpTypeChoiceNodeDownloadAllowedDirs,
+ 'node.downloadsDir': FcpTypeDirname,
+ 'node.extraPeerDataDir': FcpTypeDirname,
+ 'node.includeLocalAddressesInNoderefs': FcpTypeBool,
+ 'node.inputBandwidthLimit': FcpTypeNumBytes, # -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': FcpTypeNumBytes,
+ 'node.passOpennetPeersThroughDarknet': FcpTypeBool,
+ 'node.persistentTempDir': FcpTypeDirname,
+ 'node.storeDir': FcpTypeDirname,
+ 'node.storeForceBigShrinks': FcpTypeBool,
+ 'node.storeSize': FcpTypeNumBytes,
+ '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': FcpTypeNumBytes,
+ '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):
+ return paramName.split(self.ComponentsSep)
+
+ def splitParamClass(self, paramName):
+ return paramName.split(self.ComponentsSep, 1)
+
+
+ def get(self, paramName, default=None):
+ try:
+ return self[paramName]
+ except KeyError:
+ return default
+
+
+ def __getitem__(self, paramName):
+ paramClass, paramKey = self.splitParamClass(paramName)
+ if paramClass == self.ParamClassCurrent:
+ return self.Params[paramKey]
+ elif paramClass == self.ParamClassDefault:
+ return self.Params[paramKey]
+ elif paramClass == self.ParamClassExpertFlag:
+ return FcpTypeBool
+ elif paramClass == self.ParamClassForceWriteFlag:
+ return FcpTypeBool
+ elif paramClass == self.ParamClassShortDescription:
+ return FcpTypeString
+ elif paramClass == self.ParamClassLongDescription:
+ return FcpTypeString
+ elif paramClass == self.ParamClassSortOrder:
+ return FcpTypeInt
+ 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=GgrpsNUK9m.................................................
+>> version=Fred,0.7,1.0,1107
+>> myName=whatever
+>> ark.pubURI=SSK@...............
+
+>> dsaGroup.q=ALFDNoq.....
+>> dsaGroup.p=AIYIrE9VNhM3.............
+>> volatile.avgConnectedPeersPerNode=15.35................
+>> 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
+
+ 'ListPeer': {
+ 'WithMetadata': FcpTypeBool,
+ 'WithVolantile': FcpTypeBool,
+ },
+
+ 'ListPeers': {
+ 'WithMetadata': FcpTypeBool,
+ 'WithVolantile': FcpTypeBool,
+ },
+
+ #'AddPeer': # added later as PeerMessageParams
+
+ 'ModifyPeer': {
+ 'AllowLocalAddresses': FcpTypeBool,
+ 'IsDisabled': FcpTypeBool,
+ 'ListenOnly': FcpTypeBool,
+ },
+
+ 'ModifyPeerNote': {
+ 'NoteText': FcpTypeBase64EncodedString,
+ },
+
+ 'GetNode': {
+ 'GiveOpennetRef': FcpTypeBool,
+ 'WithPrivate': FcpTypeBool,
+ 'WithVolatile': FcpTypeBool,
+ },
+ 'GetConfig': {
+ 'WithCurrent': FcpTypeBool,
+ 'WithDefaults': FcpTypeBool,
+ 'WithSortOrder': FcpTypeBool,
+ 'WithExpertFlag': FcpTypeBool,
+ 'WithForceWriteFlag': FcpTypeBool,
+ 'WithShortDescription': FcpTypeBool,
+ 'WithLongDescription': FcpTypeBool,
+ },
+
+ #'ModifyConfig': # added later as ConfigMessageParams()
+
+ 'TestDDARequest': {
+ 'WantReadDirectory': FcpTypeBool,
+ 'WantWriteDirectory': FcpTypeBool,
+ },
+ 'ClientPut': {
+ 'BinaryBlob': FcpTypeBool,
+ 'DontCompress': FcpTypeBool,
+ 'EarlyEncode': FcpTypeBool,
+ 'GetCHKOnly': FcpTypeBool,
+ 'Global': FcpTypeBool,
+ 'MaxRetries': FcpTypeInt,
+ 'Verbosity': FcpTypeInt,
+ },
+ 'ClientGet': {
+ 'BinaryBlob': FcpTypeBool,
+ 'Global': FcpTypeBool,
+ 'IgnoreDS': FcpTypeBool,
+ 'DSOnly': FcpTypeBool,
+ 'MaxSize': FcpTypeInt,
+ 'MaxTempSize': FcpTypeInt,
+ 'Verbosity': FcpTypeInt,
+ },
+ 'SubscribeUSK': {
+ 'DontPoll': FcpTypeBool,
+ },
+ 'WatchGlobal': {
+ 'Enabled': FcpTypeBool,
+ 'VerbosityMask': FcpTypeInt,
+ },
+ 'GetRequestStatus': {
+ 'Global': FcpTypeBool,
+ 'OnlyData': FcpTypeBool,
+ },
+ 'RemopvePersistentRequest': {
+ 'Global': FcpTypeBool,
+ },
+ 'ModifyPersistentRequest': {
+ 'Global': FcpTypeBool,
+ },
+ 'GetPluginInfo': {
+ 'Detailed': FcpTypeBool,
+ },
+
+
+
+ # node messages
+
+ 'NodeHello': {
+ 'Build': FcpTypeInt,
+ 'CompressionCodecs': FcpTypeInt,
+ 'ExtBuild': FcpTypeInt,
+ 'ExtRevision': FcpTypeInt,
+ 'FcpVersion': FcpTypeFloat,
+ 'Testnet': FcpTypeBool,
+ },
+
+ #'Peer': # added later as PeerMessageParams
+
+ 'PeerNote': {
+ 'NoteText': FcpTypeBase64EncodedString,
+ },
+
+
+ #'NodeData': # added later as NodeMessageParams
+ #'ConfigData': # added later as ConfigMessageParams()
+
+ 'TestDDAComplete': {
+ 'ReadDirectoryAllowed': FcpTypeBool,
+ 'WriteDirectoryAllowed': FcpTypeBool,
+ },
+ 'PutFetchable': {
+ 'Global': FcpTypeBool,
+ },
+ 'DataFound': {
+ 'Global': FcpTypeBool,
+ 'DataLength': FcpTypeInt,
+ },
+ 'AllData': {
+ 'Global': FcpTypeBool,
+ #NOTE: we ignore startup and completion time here as long as it is not passed in all related messages
+
+ },
+ 'FinishedCompression': {
+ 'OriginalSize': FcpTypeInt,
+ 'CompressedSize': FcpTypeInt,
+ },
+ 'SimpleProgress': {
+ 'Total': FcpTypeInt,
+ 'Required': FcpTypeInt,
+ 'Failed': FcpTypeInt,
+ 'FatalyFailed': FcpTypeInt,
+ 'Succeeded': FcpTypeInt,
+ 'Finalized': FcpTypeBool,
+ },
+ 'PersistentRequestRemoved': {
+ 'Global': FcpTypeBool,
+ },
+ 'PersistentRequestModified': {
+ 'Global': FcpTypeBool,
+ },
+ 'PutFailed': {
+ 'Global': FcpTypeBool,
+ 'Code': FcpTypeInt,
+ },
+ 'GetFailed': {
+ 'Code': FcpTypeInt,
+ 'ExpectedDataLength': FcpTypeInt_GetFailed_ExpectedDataLenght,
+ 'Fatal': FcpTypeBool,
+ 'FinalizedExpected': FcpTypeBool,
+ 'Global': FcpTypeBool,
+ },
+ 'ProtocolError': {
+ 'Code': FcpTypeInt,
+ 'Global': FcpTypeBool,
+ },
+
+ 'IdentifierCollision': {
+ 'Global': FcpTypeBool,
+ },
+ 'SubscribedUSKUpdate': {
+ 'Edition': FcpTypeInt,
+ },
+ 'GetPluginInfo': {
+ 'Started': 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-02-03 13:13:51
|
Revision: 125
http://fclient.svn.sourceforge.net/fclient/?rev=125&view=rev
Author: jurner
Date: 2008-02-03 05:13:56 -0800 (Sun, 03 Feb 2008)
Log Message:
-----------
beautifications
Modified Paths:
--------------
trunk/sandbox/fcp/fcp2_0_types.py
Modified: trunk/sandbox/fcp/fcp2_0_types.py
===================================================================
--- trunk/sandbox/fcp/fcp2_0_types.py 2008-02-03 13:13:25 UTC (rev 124)
+++ trunk/sandbox/fcp/fcp2_0_types.py 2008-02-03 13:13:56 UTC (rev 125)
@@ -186,10 +186,10 @@
#
#***************************************************************************************
class ConfigMessageParams(object):
-
- ComponentsSep = '.'
+ """Parameter --> FcpType mapping for config related messages"""
-
+ ComponentSep = '.'
+
# first component of a config message param is always the param class
ParamClassCurrent = 'current'
@@ -208,9 +208,7 @@
ParamClassShortDescription,
ParamClassLongDescription,
)
-
-
-
+
# all known config keys (param class stripped)
Params = {
@@ -220,8 +218,7 @@
'console.enabled': FcpTypeBool,
'console.port': FcpTypeIPort,
'console.ssl': FcpTypeBool,
-
-
+
'fcp.allowedHosts': FcpTypeIPList,
'fcp.allowedHostsFullAccess': FcpTypeIPList,
'fcp.assumeDownloadDDAIsAllowed': FcpTypeBool,
@@ -233,8 +230,7 @@
'fcp.persistentDownloadsInterval': FcpTypeIntWithBounds(0, None),
'fcp.port': FcpTypeIPort,
'fcp.ssl': FcpTypeBool,
-
-
+
'fproxy.CSSOverride': FcpTypeBool,
'fproxy.advancedModeEnabled': FcpTypeBool,
'fproxy.allowedHosts': FcpTypeIPList,
@@ -247,18 +243,16 @@
'fproxy.port': FcpTypeIPort,
'fproxy.showPanicButton': FcpTypeBool,
'fproxy.ssl': FcpTypeBool,
-
-
+
'logger.dirname': FcpTypeDirname,
'logger.enabled': FcpTypeBool,
'logger.interval': FcpType, # ??? 1HOUR ??
'logger.maxCachedBytes': FcpTypeNumBytes,
- 'logger.maxCachedLines': FcpTypeNumBytes, # ???
+ 'logger.maxCachedLines': FcpTypeNumBytes, # ???
'logger.maxZippedLogsSize': FcpTypeNumBytes, # ???
'logger.priority': FcpTypeChoiceLoggerPriority,
'logger.priorityDetail': FcpType, # ???? is it Detailed priority thresholds ???
-
-
+
'node.alwaysAllowLocalAddresses': FcpTypeBool,
'node.assumeNATed': FcpTypeBool,
'node.bindTo': FcpTypeIP,
@@ -290,11 +284,9 @@
'node.tempIPAddressHint': FcpTypeIP, # ???
'node.testingDropPacketsEvery': FcpTypeIntWithBounds(0, None),
'node.uploadAllowedDirs': FcpTypeChoiceNodeDownloadAllowedDirs,
-
-
- 'node.testnet.enabled': FcpTypeBool,
-
+ 'node.testnet.enabled': FcpTypeBool,
+
'node.load.aggressiveGC': FcpType, # ???
'node.load.freeHeapBytesThreshold': FcpTypeNumBytes,
'node.load.freeHeapPercentThreshold': FcpTypePercent,
@@ -302,7 +294,6 @@
'node.load.nodeThrottleFile': FcpTypeFilename,
'node.load.threadLimit': FcpTypeIntWithBounds(0, None),
-
'node.opennet.acceptSeedConnections': FcpTypeBool,
'node.opennet.alwaysAllowLocalAddresses': FcpTypeBool,
'node.opennet.assumeNATed': FcpTypeBool,
@@ -324,11 +315,9 @@
'node.updater.extURI': FcpTypeUri,
'node.updater.revocationURI': FcpTypeUri,
-
'pluginmanager.loadplugin': FcpTypeStringList,
'pluginmanager2.loadedPlugins': FcpTypeStringList,
-
-
+
'ssl.sslEnable': FcpTypeBool,
'ssl.sslKeyPass': FcpTypeString,
'ssl.sslKeyStore': FcpTypeFilename,
@@ -336,22 +325,32 @@
'ssl.sslVersion': FcpTypeChoiceSSLVersion,
'toadletsymlinker.symlinks': FcpTypeStringList,
-
}
-
def __init__(self):
pass
-
def splitAll(self, paramName):
- return paramName.split(self.ComponentsSep)
+ """Splits a parameter name into its components
+ @param (str) paramName: parameter name to split
+ @return: (list) components
+ """
+ return paramName.split(self.ComponentSep)
+
def splitParamClass(self, paramName):
- return paramName.split(self.ComponentsSep, 1)
+ """Splits the parameter class from a parameter name
+ @param (str) paramName: parameter name to split
+ @return: (tuple) paramClass, tail
+ """
+ return paramName.split(self.ComponentSep, 1)
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:
@@ -359,6 +358,10 @@
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 == self.ParamClassCurrent:
return self.Params[paramKey]
@@ -387,8 +390,7 @@
PeerMessageParams = {
'ark.number': FcpTypeInt,
'auth.negTypes': FcpTypeInt,
-
-
+
'location': FcpTypeFloat,
'opennet': FcpTypeBool,
'testnet': FcpTypeBool,
@@ -440,8 +442,7 @@
'location': FcpTypeFloat,
'opennet': FcpTypeBool,
'testnet': FcpTypeBool,
-
-
+
'volatile.allocatedJavaMemory': FcpTypeInt,
'volatile.availableCPUs': FcpTypeInt,
'volatile.averagePingTime': FcpTypeFloat,
@@ -527,14 +528,14 @@
>>all other NodeData message params here....
>>
>> physical.udp=000.000.000.000:00000
->> dsaPubKey.y=GgrpsNUK9m.................................................
+>> dsaPubKey.y=GarpsNUKe.................................................
>> version=Fred,0.7,1.0,1107
>> myName=whatever
>> ark.pubURI=SSK@...............
>> dsaGroup.q=ALFDNoq.....
>> dsaGroup.p=AIYIrE9VNhM3.............
->> volatile.avgConnectedPeersPerNode=15.35................
+>> volatile.avgConnectedPeersPerNode=00.00................
>> dsaGroup.g=UaRa.............
>> dsaPrivKey.x=Pwam..................
>> ark.privURI=SSK@.................
@@ -553,93 +554,111 @@
MessageParamTypes = {
# client messages
-
+ #
+ #'AddPeer': # added later as PeerMessageParams
+ 'ClientGet': {
+ 'BinaryBlob': FcpTypeBool,
+ 'Global': FcpTypeBool,
+ 'IgnoreDS': FcpTypeBool,
+ 'DSOnly': FcpTypeBool,
+ 'MaxSize': FcpTypeInt,
+ 'MaxTempSize': FcpTypeInt,
+ 'Verbosity': FcpTypeInt,
+ },
+ 'ClientPut': {
+ 'BinaryBlob': FcpTypeBool,
+ 'DontCompress': FcpTypeBool,
+ 'EarlyEncode': FcpTypeBool,
+ 'GetCHKOnly': FcpTypeBool,
+ 'Global': FcpTypeBool,
+ 'MaxRetries': FcpTypeInt,
+ 'Verbosity': 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,
},
-
- #'AddPeer': # added later as PeerMessageParams
-
'ModifyPeer': {
'AllowLocalAddresses': FcpTypeBool,
'IsDisabled': FcpTypeBool,
'ListenOnly': FcpTypeBool,
},
-
+ #'ModifyConfig': # added later as ConfigMessageParams()
'ModifyPeerNote': {
'NoteText': FcpTypeBase64EncodedString,
},
-
- 'GetNode': {
- 'GiveOpennetRef': FcpTypeBool,
- 'WithPrivate': FcpTypeBool,
- 'WithVolatile': FcpTypeBool,
+ 'ModifyPersistentRequest': {
+ 'Global': FcpTypeBool,
},
- 'GetConfig': {
- 'WithCurrent': FcpTypeBool,
- 'WithDefaults': FcpTypeBool,
- 'WithSortOrder': FcpTypeBool,
- 'WithExpertFlag': FcpTypeBool,
- 'WithForceWriteFlag': FcpTypeBool,
- 'WithShortDescription': FcpTypeBool,
- 'WithLongDescription': FcpTypeBool,
- },
-
- #'ModifyConfig': # added later as ConfigMessageParams()
-
- 'TestDDARequest': {
- 'WantReadDirectory': FcpTypeBool,
- 'WantWriteDirectory': FcpTypeBool,
- },
- 'ClientPut': {
- 'BinaryBlob': FcpTypeBool,
- 'DontCompress': FcpTypeBool,
- 'EarlyEncode': FcpTypeBool,
- 'GetCHKOnly': FcpTypeBool,
+ 'RemopvePersistentRequest': {
'Global': FcpTypeBool,
- 'MaxRetries': FcpTypeInt,
- 'Verbosity': FcpTypeInt,
},
- 'ClientGet': {
- 'BinaryBlob': FcpTypeBool,
- 'Global': FcpTypeBool,
- 'IgnoreDS': FcpTypeBool,
- 'DSOnly': FcpTypeBool,
- 'MaxSize': FcpTypeInt,
- 'MaxTempSize': FcpTypeInt,
- 'Verbosity': FcpTypeInt,
- },
'SubscribeUSK': {
'DontPoll': FcpTypeBool,
},
+ 'TestDDARequest': {
+ 'WantReadDirectory': FcpTypeBool,
+ 'WantWriteDirectory': FcpTypeBool,
+ },
'WatchGlobal': {
'Enabled': FcpTypeBool,
'VerbosityMask': FcpTypeInt,
},
- 'GetRequestStatus': {
+
+ # node messages
+ #
+ 'AllData': {
'Global': FcpTypeBool,
- 'OnlyData': FcpTypeBool,
+ #NOTE: we ignore startup and completion time here as long as it is not passed in all related messages
},
- 'RemopvePersistentRequest': {
+ #'ConfigData': # added later as ConfigMessageParams()
+ 'DataFound': {
'Global': FcpTypeBool,
+ 'DataLength': FcpTypeInt,
},
- 'ModifyPersistentRequest': {
- 'Global': FcpTypeBool,
+ 'FinishedCompression': {
+ 'OriginalSize': FcpTypeInt,
+ 'CompressedSize': FcpTypeInt,
},
+ 'GetFailed': {
+ 'Code': FcpTypeInt,
+ 'ExpectedDataLength': FcpTypeInt_GetFailed_ExpectedDataLenght,
+ 'Fatal': FcpTypeBool,
+ 'FinalizedExpected': FcpTypeBool,
+ 'Global': FcpTypeBool,
+ },
'GetPluginInfo': {
- 'Detailed': FcpTypeBool,
+ 'Started': FcpTypeBool,
},
-
-
-
- # node messages
-
+ 'IdentifierCollision': {
+ 'Global': FcpTypeBool,
+ },
+ #'NodeData': # added later as NodeMessageParams
'NodeHello': {
'Build': FcpTypeInt,
'CompressionCodecs': FcpTypeInt,
@@ -648,37 +667,27 @@
'FcpVersion': FcpTypeFloat,
'Testnet': FcpTypeBool,
},
-
#'Peer': # added later as PeerMessageParams
-
'PeerNote': {
'NoteText': FcpTypeBase64EncodedString,
},
-
-
- #'NodeData': # added later as NodeMessageParams
- #'ConfigData': # added later as ConfigMessageParams()
-
- 'TestDDAComplete': {
- 'ReadDirectoryAllowed': FcpTypeBool,
- 'WriteDirectoryAllowed': FcpTypeBool,
- },
- 'PutFetchable': {
+ 'PersistentRequestModified': {
'Global': FcpTypeBool,
- },
- 'DataFound': {
+ },
+ 'PersistentRequestRemoved': {
'Global': FcpTypeBool,
- 'DataLength': FcpTypeInt,
},
- 'AllData': {
+ 'ProtocolError': {
+ 'Code': FcpTypeInt,
'Global': FcpTypeBool,
- #NOTE: we ignore startup and completion time here as long as it is not passed in all related messages
-
+ },
+ 'PutFailed': {
+ 'Global': FcpTypeBool,
+ 'Code': FcpTypeInt,
+ },
+ 'PutFetchable': {
+ 'Global': FcpTypeBool,
},
- 'FinishedCompression': {
- 'OriginalSize': FcpTypeInt,
- 'CompressedSize': FcpTypeInt,
- },
'SimpleProgress': {
'Total': FcpTypeInt,
'Required': FcpTypeInt,
@@ -687,38 +696,13 @@
'Succeeded': FcpTypeInt,
'Finalized': FcpTypeBool,
},
- 'PersistentRequestRemoved': {
- 'Global': FcpTypeBool,
- },
- 'PersistentRequestModified': {
- 'Global': FcpTypeBool,
- },
- 'PutFailed': {
- 'Global': FcpTypeBool,
- 'Code': FcpTypeInt,
- },
- 'GetFailed': {
- 'Code': FcpTypeInt,
- 'ExpectedDataLength': FcpTypeInt_GetFailed_ExpectedDataLenght,
- 'Fatal': FcpTypeBool,
- 'FinalizedExpected': FcpTypeBool,
- 'Global': FcpTypeBool,
- },
- 'ProtocolError': {
- 'Code': FcpTypeInt,
- 'Global': FcpTypeBool,
- },
-
- 'IdentifierCollision': {
- 'Global': FcpTypeBool,
- },
'SubscribedUSKUpdate': {
'Edition': FcpTypeInt,
},
- 'GetPluginInfo': {
- 'Started': FcpTypeBool,
+ 'TestDDAComplete': {
+ 'ReadDirectoryAllowed': FcpTypeBool,
+ 'WriteDirectoryAllowed': FcpTypeBool,
},
-
}
MessageParamTypes['ClientPutDiskDir'] = MessageParamTypes['ClientPut']
@@ -728,9 +712,7 @@
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-02-04 03:16:16
|
Revision: 131
http://fclient.svn.sourceforge.net/fclient/?rev=131&view=rev
Author: jurner
Date: 2008-02-03 19:16:21 -0800 (Sun, 03 Feb 2008)
Log Message:
-----------
for completeness, added ClientHello to types
Modified Paths:
--------------
trunk/sandbox/fcp/fcp2_0_types.py
Modified: trunk/sandbox/fcp/fcp2_0_types.py
===================================================================
--- trunk/sandbox/fcp/fcp2_0_types.py 2008-02-04 03:14:49 UTC (rev 130)
+++ trunk/sandbox/fcp/fcp2_0_types.py 2008-02-04 03:16:21 UTC (rev 131)
@@ -332,7 +332,7 @@
def splitAll(self, paramName):
"""Splits a parameter name into its components
- @param (str) paramName: parameter name to split
+ @param paramName: (str) parameter name to split
@return: (list) components
"""
return paramName.split(self.ComponentSep)
@@ -340,7 +340,7 @@
def splitParamClass(self, paramName):
"""Splits the parameter class from a parameter name
- @param (str) paramName: parameter name to split
+ @param paramName: (str) parameter name to split
@return: (tuple) paramClass, tail
"""
return paramName.split(self.ComponentSep, 1)
@@ -565,6 +565,9 @@
'MaxTempSize': FcpTypeInt,
'Verbosity': FcpTypeInt,
},
+ 'ClientHello': {
+ 'ExpectedVersion': FcpTypeInt,
+ },
'ClientPut': {
'BinaryBlob': FcpTypeBool,
'DontCompress': FcpTypeBool,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ju...@us...> - 2008-02-04 11:54:33
|
Revision: 138
http://fclient.svn.sourceforge.net/fclient/?rev=138&view=rev
Author: jurner
Date: 2008-02-04 03:53:43 -0800 (Mon, 04 Feb 2008)
Log Message:
-----------
fixes
Modified Paths:
--------------
trunk/sandbox/fcp/fcp2_0_types.py
Modified: trunk/sandbox/fcp/fcp2_0_types.py
===================================================================
--- trunk/sandbox/fcp/fcp2_0_types.py 2008-02-04 11:53:08 UTC (rev 137)
+++ trunk/sandbox/fcp/fcp2_0_types.py 2008-02-04 11:53:43 UTC (rev 138)
@@ -561,12 +561,13 @@
'Global': FcpTypeBool,
'IgnoreDS': FcpTypeBool,
'DSOnly': FcpTypeBool,
+ 'MaxRetries': FcpTypeInt,
'MaxSize': FcpTypeInt,
'MaxTempSize': FcpTypeInt,
'Verbosity': FcpTypeInt,
},
'ClientHello': {
- 'ExpectedVersion': FcpTypeInt,
+ 'ExpectedVersion': FcpTypeFloat,
},
'ClientPut': {
'BinaryBlob': FcpTypeBool,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ju...@us...> - 2008-02-12 15:59:45
|
Revision: 212
http://fclient.svn.sourceforge.net/fclient/?rev=212&view=rev
Author: jurner
Date: 2008-02-12 07:59:48 -0800 (Tue, 12 Feb 2008)
Log Message:
-----------
Wrong param name in SimpleProgress. It's "FinalzedTotal" not "Fianlized"
Modified Paths:
--------------
trunk/sandbox/fcp/fcp2_0_types.py
Modified: trunk/sandbox/fcp/fcp2_0_types.py
===================================================================
--- trunk/sandbox/fcp/fcp2_0_types.py 2008-02-12 15:57:09 UTC (rev 211)
+++ trunk/sandbox/fcp/fcp2_0_types.py 2008-02-12 15:59:48 UTC (rev 212)
@@ -698,7 +698,7 @@
'Failed': FcpTypeInt,
'FatalyFailed': FcpTypeInt,
'Succeeded': FcpTypeInt,
- 'Finalized': FcpTypeBool,
+ 'FinalizedTotal': FcpTypeBool,
},
'SubscribedUSKUpdate': {
'Edition': FcpTypeInt,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ju...@us...> - 2008-02-16 10:09:21
|
Revision: 217
http://fclient.svn.sourceforge.net/fclient/?rev=217&view=rev
Author: jurner
Date: 2008-02-16 02:09:26 -0800 (Sat, 16 Feb 2008)
Log Message:
-----------
added a few new config params
still working on how to handle byte amounts and time deltas
Modified Paths:
--------------
trunk/sandbox/fcp/fcp2_0_types.py
Modified: trunk/sandbox/fcp/fcp2_0_types.py
===================================================================
--- trunk/sandbox/fcp/fcp2_0_types.py 2008-02-16 10:07:55 UTC (rev 216)
+++ trunk/sandbox/fcp/fcp2_0_types.py 2008-02-16 10:09:26 UTC (rev 217)
@@ -3,6 +3,24 @@
This module handles type conversions from Fcp to Python and vice versa
"""
+import os, sys
+
+#--> rel import hack
+class SysPathHack(object):
+ def __init__(self, n):
+ fpath = os.path.abspath(__file__)
+ for i in xrange(n): fpath = os.path.dirname(fpath)
+ sys.path.insert(0, fpath)
+ def __del__(self): sys.path.pop(0)
+hack = SysPathHack(3)
+
+
+from fcp_lib import numbers
+
+
+del hack
+#<-- rel import hack
+
import base64
import fcp2_0_consts as consts
@@ -112,7 +130,8 @@
def fcpToPython(clss, value):
return int(value) / 1000
-
+#TODO: how to handle time deltas? Convert them to seconds?
+class FcpTypeTimeDelta(FcpType): pass
class FcpTypeIP(FcpType): pass
class FcpTypeIPList(FcpType): pass
@@ -120,7 +139,37 @@
class FcpTypeStringList(FcpType): pass
class FcpTypeDirname(FcpType): pass
class FcpTypeFilename(FcpType): pass
-class FcpTypeNumBytes(FcpType): pass
+
+#TODO: how to handle byte amounts? Convert them to (int) bytes?
+class FcpTypeNumBytes(FcpType):
+ """Type conversion """
+
+ 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)
+
+ @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
+
+
+
+
class FcpTypePercent(FcpTypeFloat): pass
class FcpTypeUri(FcpType): pass
@@ -207,6 +256,7 @@
ParamClassForceWriteFlag,
ParamClassShortDescription,
ParamClassLongDescription,
+ ParamClassSortOrder,
)
# all known config keys (param class stripped)
@@ -227,7 +277,7 @@
'fcp.enabled': FcpTypeBool,
'fcp.persistentDownloadsEnabled': FcpTypeBool,
'fcp.persistentDownloadsFile': FcpTypeFilename,
- 'fcp.persistentDownloadsInterval': FcpTypeIntWithBounds(0, None),
+ 'fcp.persistentDownloadsInterval': FcpTypeTimeDelta,
'fcp.port': FcpTypeIPort,
'fcp.ssl': FcpTypeBool,
@@ -246,7 +296,7 @@
'logger.dirname': FcpTypeDirname,
'logger.enabled': FcpTypeBool,
- 'logger.interval': FcpType, # ??? 1HOUR ??
+ 'logger.interval': FcpTypeTimeDelta,
'logger.maxCachedBytes': FcpTypeNumBytes,
'logger.maxCachedLines': FcpTypeNumBytes, # ???
'logger.maxZippedLogsSize': FcpTypeNumBytes, # ???
@@ -262,6 +312,11 @@
'node.disableProbabilisticHTLs': FcpTypeBool,
'node.downloadAllowedDirs': FcpTypeChoiceNodeDownloadAllowedDirs,
'node.downloadsDir': FcpTypeDirname,
+ 'node.enableARKs': FcpTypeBool,
+ 'node.enablePerNodeFailureTables': FcpTypeBool,
+ 'node.enableSwapping': FcpTypeBool,
+ 'node.enableSwapQueueing': FcpTypeBool,
+ 'node.enableULPRDataPropagation': FcpTypeBool,
'node.extraPeerDataDir': FcpTypeDirname,
'node.includeLocalAddressesInNoderefs': FcpTypeBool,
'node.inputBandwidthLimit': FcpTypeNumBytes, # -1 is possible as value aswell
@@ -280,6 +335,7 @@
'node.storeDir': FcpTypeDirname,
'node.storeForceBigShrinks': FcpTypeBool,
'node.storeSize': FcpTypeNumBytes,
+ 'node.storeType': FcpTypeString,
'node.tempDir': FcpTypeDirname,
'node.tempIPAddressHint': FcpTypeIP, # ???
'node.testingDropPacketsEvery': FcpTypeIntWithBounds(0, None),
@@ -343,7 +399,11 @@
@param paramName: (str) parameter name to split
@return: (tuple) paramClass, tail
"""
- return paramName.split(self.ComponentSep, 1)
+ result = paramName.split(self.ComponentSep, 1)
+ if len(result) == 2:
+ if result[0] in self.ParamClasses:
+ return result
+ return '', paramName
def get(self, paramName, default=None):
@@ -363,7 +423,7 @@
@return: (FcpType)
"""
paramClass, paramKey = self.splitParamClass(paramName)
- if paramClass == self.ParamClassCurrent:
+ if paramClass == self.ParamClassCurrent or paramClass == '':
return self.Params[paramKey]
elif paramClass == self.ParamClassDefault:
return self.Params[paramKey]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ju...@us...> - 2008-02-21 13:10:12
|
Revision: 237
http://fclient.svn.sourceforge.net/fclient/?rev=237&view=rev
Author: jurner
Date: 2008-02-21 05:10:08 -0800 (Thu, 21 Feb 2008)
Log Message:
-----------
fix: someone set ExtRevision to '@custom@'. Heh! See if we can get away with our int / float conversions
Modified Paths:
--------------
trunk/sandbox/fcp/fcp2_0_types.py
Modified: trunk/sandbox/fcp/fcp2_0_types.py
===================================================================
--- trunk/sandbox/fcp/fcp2_0_types.py 2008-02-21 13:08:36 UTC (rev 236)
+++ trunk/sandbox/fcp/fcp2_0_types.py 2008-02-21 13:10:08 UTC (rev 237)
@@ -727,7 +727,7 @@
'Build': FcpTypeInt,
'CompressionCodecs': FcpTypeInt,
'ExtBuild': FcpTypeInt,
- 'ExtRevision': FcpTypeInt,
+ #'ExtRevision': FcpTypeInt,
'FcpVersion': FcpTypeFloat,
'Testnet': FcpTypeBool,
},
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|