diff options
author | elie <elie> | 2015-09-27 10:26:25 +0000 |
---|---|---|
committer | elie <elie> | 2015-09-27 10:26:25 +0000 |
commit | 627d9ff4a3715477e56fe397f099ad0db0d5c1b9 (patch) | |
tree | 60cdd6f446e892194122abad0dfa4c6413eb4374 /pysnmp/entity/rfc3413/twisted | |
parent | bdfbce73382678e0288d8bc8d3093c827b05e1d1 (diff) | |
download | pysnmp-627d9ff4a3715477e56fe397f099ad0db0d5c1b9.tar.gz |
* Asyncore and asyncio-based APIs reworked to become functions.
* Asyncio and Twisted API moved entirely into high-level domain to
be aligned with other high-level APIs. This WILL BREAK backward
compatibility for those apps that use Twisted API.
Diffstat (limited to 'pysnmp/entity/rfc3413/twisted')
-rw-r--r-- | pysnmp/entity/rfc3413/twisted/__init__.py | 1 | ||||
-rw-r--r-- | pysnmp/entity/rfc3413/twisted/cmdgen.py | 136 | ||||
-rw-r--r-- | pysnmp/entity/rfc3413/twisted/ntforg.py | 75 |
3 files changed, 0 insertions, 212 deletions
diff --git a/pysnmp/entity/rfc3413/twisted/__init__.py b/pysnmp/entity/rfc3413/twisted/__init__.py deleted file mode 100644 index 8c3066b..0000000 --- a/pysnmp/entity/rfc3413/twisted/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# This file is necessary to make this directory a package. diff --git a/pysnmp/entity/rfc3413/twisted/cmdgen.py b/pysnmp/entity/rfc3413/twisted/cmdgen.py deleted file mode 100644 index 40f5464..0000000 --- a/pysnmp/entity/rfc3413/twisted/cmdgen.py +++ /dev/null @@ -1,136 +0,0 @@ -from twisted.internet import defer -from pysnmp.entity.rfc3413 import cmdgen - -def _cbFun(snmpEngine, sendRequestHandle, errorIndication, - errorStatus, errorIndex, varBinds, cbCtx): - df = cbCtx['df'] - df.callback( - (snmpEngine, errorIndication, errorStatus, errorIndex, varBinds) - ) - # Callback function may return another deferred to indicate - # it wishes to continue MIB walk. - if isinstance(df.result, defer.Deferred): - cbCtx['df'] = df.result - return 1 # continue walking - -class AbstractCommandGenerator: - commandGenerator = None - - def sendVarBinds(self, snmpEngine, targetName, - contextEngineId, contextName, varBinds): - df = defer.Deferred() - self.commandGenerator.sendVarBinds( - snmpEngine, - targetName, - contextEngineId, - contextName, - varBinds, - _cbFun, - { 'df': df } # anonymous dictionary used for cbCtx - ) - return df - -class GetCommandGenerator(AbstractCommandGenerator): - commandGenerator = cmdgen.GetCommandGenerator() - -class SetCommandGenerator(AbstractCommandGenerator): - commandGenerator = cmdgen.SetCommandGenerator() - -class NextCommandGeneratorSingleRun(AbstractCommandGenerator): - commandGenerator = cmdgen.NextCommandGeneratorSingleRun() - -class NextCommandGenerator(AbstractCommandGenerator): - commandGenerator = cmdgen.NextCommandGenerator() - -class AbstractBulkCommandGenerator: - commandGenerator = None - - def sendVarBinds( - self, - snmpEngine, - targetName, - contextEngineId, - contextName, - nonRepeaters, - maxRepetitions, - varBinds - ): - df = defer.Deferred() - self.commandGenerator.sendVarBinds( - snmpEngine, - targetName, - contextEngineId, - contextName, - nonRepeaters, - maxRepetitions, - varBinds, - _cbFun, - { 'df': df } # anonymous dictionary used for cbCtx - ) - return df - -class BulkCommandGeneratorSingleRun(AbstractBulkCommandGenerator): - commandGenerator = cmdgen.BulkCommandGeneratorSingleRun() - -class BulkCommandGenerator(AbstractBulkCommandGenerator): - commandGenerator = cmdgen.BulkCommandGenerator() - -# -# Obsolete, compatibility interfaces. -# - -def __sendReqCbFun(response, outerDf): - ( snmpEngine, - errorIndication, - errorStatus, - errorIndex, - varBinds) = response - outerDf.callback((errorIndication, errorStatus, errorIndex, varBinds)) - # Callback function may return another deferred to indicate - # it wishes to continue MIB walk. - if isinstance(outerDf.result, defer.Deferred): - innerDf = defer.Deferred() - innerDf.addCallback(__sendReqCbFun, outerDf.result) - return innerDf - -def _sendReq(self, - snmpEngine, - targetName, - varBinds, - contextEngineId=None, - contextName=''): - innerDf = self.sendVarBinds(snmpEngine, - targetName, - contextEngineId, - contextName, - varBinds) - outerDf = defer.Deferred() - innerDf.addCallback(__sendReqCbFun, outerDf) - return outerDf - -def _sendBulkReq(self, - snmpEngine, - targetName, - nonRepeaters, - maxRepetitions, - varBinds, - contextEngineId=None, - contextName=''): - innerDf = self.sendVarBinds(snmpEngine, - targetName, - contextEngineId, - contextName, - nonRepeaters, - maxRepetitions, - varBinds) - outerDf = defer.Deferred() - innerDf.addCallback(__sendReqCbFun, outerDf) - return outerDf - -# install compatibility wrappers -GetCommandGenerator.sendReq = _sendReq -SetCommandGenerator.sendReq = _sendReq -NextCommandGenerator.sendReq = _sendReq -NextCommandGeneratorSingleRun.sendReq = _sendReq -BulkCommandGenerator.sendReq = _sendBulkReq -BulkCommandGeneratorSingleRun.sendReq = _sendBulkReq diff --git a/pysnmp/entity/rfc3413/twisted/ntforg.py b/pysnmp/entity/rfc3413/twisted/ntforg.py deleted file mode 100644 index cc796b6..0000000 --- a/pysnmp/entity/rfc3413/twisted/ntforg.py +++ /dev/null @@ -1,75 +0,0 @@ -from twisted.internet import defer -from pysnmp.entity.rfc3413 import ntforg -from pyasn1.compat.octets import null - -def __cbFun(snmpEngine, sendRequestHandle, errorIndication, - errorStatus, errorIndex, varBinds, cbCtx): - cbCtx.callback( - (snmpEngine, errorIndication, errorStatus, errorIndex, varBinds) - ) - -class NotificationOriginator: - def __init__(self, snmpContext=None): - self.snmpContext = snmpContext # this is deprecated - self.notificationOriginator = ntforg.NotificationOriginator() - - def sendVarBinds(self, - snmpEngine, - notificationTarget, - snmpContext, - contextName, - notificationName, - instanceIndex, - additionalVarBinds=()): - df = defer.Deferred() - self.notificationOriginator.sendVarBinds( - snmpEngine, - notificationTarget, - snmpContext, - contextName, - notificationName, - instanceIndex, - additionalVarBinds, - __cbFun, - df - ) - return df - -# -# Obsolete, compatibility interfaces. -# - -def __sendReqCbFun(response, outerDf): - ( snmpEngine, - errorIndication, - errorStatus, - errorIndex, - varBinds) = response - outerDf.callback((errorIndication, errorStatus, errorIndex, varBinds)) - # Callback function may return another deferred to indicate - # it wishes to continue MIB walk. - if isinstance(outerDf.result, defer.Deferred): - innerDf = defer.Deferred() - innerDf.addCallback(__sendReqCbFun, outerDf.result) - return innerDf - -def _sendNotification(self, - snmpEngine, - notificationTarget, - notificationName, - additionalVarBinds=None, - contextName=null): - - innerDf = self.sendVarBinds(snmpEngine, - notificationTarget, - self.snmpContext, - contextName, - notificationName, - None, - additionalVarBinds) - outerDf = defer.Deferred() - innerDf.addCallback(__sendReqCbFun, outerDf) - return outerDf - -# install compatibility wrappers -NotificationOriginator.sendNotification = _sendNotification |