summaryrefslogtreecommitdiff
path: root/pysnmp/entity
diff options
context:
space:
mode:
authorelie <elie>2015-10-17 20:22:30 +0000
committerelie <elie>2015-10-17 20:22:30 +0000
commita46f37c26520015e3ad8628587db3899f55d8c33 (patch)
tree6798d1e7f1a5bac03b595d4e6b27b8735bb9c1eb /pysnmp/entity
parent9e73d5b89c6121437b92f02482b4423ab526b51a (diff)
downloadpysnmp-git-a46f37c26520015e3ad8628587db3899f55d8c33.tar.gz
linted for bad-whitespace and some other issues
Diffstat (limited to 'pysnmp/entity')
-rw-r--r--pysnmp/entity/config.py26
-rw-r--r--pysnmp/entity/rfc3413/cmdgen.py446
-rw-r--r--pysnmp/entity/rfc3413/cmdrsp.py26
-rw-r--r--pysnmp/entity/rfc3413/config.py6
-rw-r--r--pysnmp/entity/rfc3413/context.py2
-rw-r--r--pysnmp/entity/rfc3413/mibvar.py2
-rw-r--r--pysnmp/entity/rfc3413/ntforg.py2
-rw-r--r--pysnmp/entity/rfc3413/oneliner/cmdgen.py37
8 files changed, 168 insertions, 379 deletions
diff --git a/pysnmp/entity/config.py b/pysnmp/entity/config.py
index 3e323403..59ac864e 100644
--- a/pysnmp/entity/config.py
+++ b/pysnmp/entity/config.py
@@ -199,7 +199,7 @@ def delV3User(snmpEngine,
)
if varBinds[0][1].isSameTypeWith(rfc1905.endOfMibView):
break
- if varBinds[0][0][:len(initialVarBinds[0][0])]!=initialVarBinds[0][0]:
+ if varBinds[0][0][:len(initialVarBinds[0][0])] != initialVarBinds[0][0]:
break
elif varBinds[2][1] == tblIdx1: # cloned from this entry
delV3User(snmpEngine, varBinds[1][1], varBinds[0][1])
@@ -509,11 +509,13 @@ def delRwUser(snmpEngine, securityModel, securityName, securityLevel, subTree):
delVacmUser(snmpEngine, securityModel, securityName, securityLevel,
subTree, subTree)
-def addTrapUser(snmpEngine,securityModel,securityName,securityLevel,subTree):
+def addTrapUser(snmpEngine, securityModel, securityName,
+ securityLevel, subTree):
addVacmUser(snmpEngine, securityModel, securityName, securityLevel,
(), (), subTree)
-def delTrapUser(snmpEngine,securityModel,securityName,securityLevel,subTree):
+def delTrapUser(snmpEngine, securityModel, securityName,
+ securityLevel, subTree):
delVacmUser(snmpEngine, securityModel, securityName, securityLevel,
(), (), subTree)
@@ -619,9 +621,15 @@ def setInitialVacmParameters(snmpEngine):
"internet", "internet", "internet")
# rfc3415: A.1.5 (semi-secure)
- addVacmView(snmpEngine, "internet", "included", (1,3,6,1),"")
- addVacmView(snmpEngine, "restricted", "included", (1,3,6,1,2,1,1),"")
- addVacmView(snmpEngine, "restricted", "included", (1,3,6,1,2,1,11),"")
- addVacmView(snmpEngine, "restricted", "included", (1,3,6,1,6,3,10,2,1),"")
- addVacmView(snmpEngine, "restricted", "included", (1,3,6,1,6,3,11,2,1),"")
- addVacmView(snmpEngine, "restricted", "included", (1,3,6,1,6,3,15,1,1),"")
+ addVacmView(snmpEngine, "internet",
+ "included", (1, 3, 6, 1), "")
+ addVacmView(snmpEngine, "restricted",
+ "included", (1, 3, 6, 1, 2, 1, 1), "")
+ addVacmView(snmpEngine, "restricted",
+ "included", (1, 3, 6, 1, 2, 1, 11), "")
+ addVacmView(snmpEngine, "restricted",
+ "included", (1, 3, 6, 1, 6, 3, 10, 2, 1), "")
+ addVacmView(snmpEngine, "restricted",
+ "included", (1, 3, 6, 1, 6, 3, 11, 2, 1), "")
+ addVacmView(snmpEngine, "restricted",
+ "included", (1, 3, 6, 1, 6, 3, 15, 1, 1), "")
diff --git a/pysnmp/entity/rfc3413/cmdgen.py b/pysnmp/entity/rfc3413/cmdgen.py
index 6f61dedb..ab68148e 100644
--- a/pysnmp/entity/rfc3413/cmdgen.py
+++ b/pysnmp/entity/rfc3413/cmdgen.py
@@ -37,38 +37,22 @@ class CommandGenerator:
def __init__(self):
self.__pendingReqs = {}
- def processResponsePdu(self,
- snmpEngine,
- messageProcessingModel,
- securityModel,
- securityName,
- securityLevel,
- contextEngineId,
- contextName,
- pduVersion,
- PDU,
- statusInformation,
- sendPduHandle,
- cbCtx):
+ def processResponsePdu(self, snmpEngine, messageProcessingModel,
+ securityModel, securityName, securityLevel,
+ contextEngineId, contextName, pduVersion,
+ PDU, statusInformation, sendPduHandle, cbCtx):
origSendRequestHandle, cbFun, cbCtx = cbCtx
# 3.1.1
if sendPduHandle not in self.__pendingReqs:
raise error.PySnmpError('Missing sendPduHandle %s' % sendPduHandle)
- ( origTransportDomain,
- origTransportAddress,
- origMessageProcessingModel,
- origSecurityModel,
- origSecurityName,
- origSecurityLevel,
- origContextEngineId,
- origContextName,
- origPduVersion,
- origPdu,
- origTimeout,
- origRetryCount,
- origRetries ) = self.__pendingReqs.pop(sendPduHandle)
+ (origTransportDomain, origTransportAddress,
+ origMessageProcessingModel, origSecurityModel,
+ origSecurityName, origSecurityLevel, origContextEngineId,
+ origContextName, origPduVersion, origPdu,
+ origTimeout, origRetryCount,
+ origRetries) = self.__pendingReqs.pop(sendPduHandle)
snmpEngine.transportDispatcher.jobFinished(id(self))
@@ -84,58 +68,35 @@ class CommandGenerator:
errind.unknownEngineID) and \
origRetries == origRetryCount:
debug.logger & debug.flagApp and debug.logger('processResponsePdu: sendPduHandle %s, retry count %d exceeded' % (sendPduHandle, origRetries))
- cbFun(snmpEngine,
- origSendRequestHandle,
- statusInformation['errorIndication'],
- None,
- cbCtx)
+ cbFun(snmpEngine, origSendRequestHandle,
+ statusInformation['errorIndication'], None, cbCtx)
return
try:
sendPduHandle = snmpEngine.msgAndPduDsp.sendPdu(
- snmpEngine,
- origTransportDomain,
- origTransportAddress,
- origMessageProcessingModel,
- origSecurityModel,
- origSecurityName,
- origSecurityLevel,
- origContextEngineId,
- origContextName,
- origPduVersion,
- origPdu,
- True, # expectResponse
- origTimeout, # already in ticks
- self.processResponsePdu,
- (origSendRequestHandle, cbFun, cbCtx)
- )
+ snmpEngine, origTransportDomain, origTransportAddress,
+ origMessageProcessingModel, origSecurityModel,
+ origSecurityName, origSecurityLevel, origContextEngineId,
+ origContextName, origPduVersion, origPdu,
+ True, origTimeout, self.processResponsePdu,
+ (origSendRequestHandle, cbFun, cbCtx))
snmpEngine.transportDispatcher.jobStarted(id(self))
self.__pendingReqs[sendPduHandle] = (
- origTransportDomain,
- origTransportAddress,
- origMessageProcessingModel,
- origSecurityModel,
- origSecurityName,
- origSecurityLevel,
- origContextEngineId,
- origContextName,
- origPduVersion,
- origPdu,
- origTimeout,
- origRetryCount,
- origRetries + 1
+ origTransportDomain, origTransportAddress,
+ origMessageProcessingModel, origSecurityModel,
+ origSecurityName, origSecurityLevel, origContextEngineId,
+ origContextName, origPduVersion, origPdu, origTimeout,
+ origRetryCount, origRetries + 1
)
return
except StatusInformation:
statusInformation = sys.exc_info()[1]
debug.logger & debug.flagApp and debug.logger('processResponsePdu: origSendRequestHandle %s, _sendPdu() failed with %r' % (sendPduHandle, statusInformation))
- cbFun(snmpEngine,
- origSendRequestHandle,
+ cbFun(snmpEngine, origSendRequestHandle,
statusInformation['errorIndication'],
- None,
- cbCtx)
+ None, cbCtx)
return
if origMessageProcessingModel != messageProcessingModel or \
@@ -146,11 +107,8 @@ class CommandGenerator:
origPduVersion != pduVersion:
debug.logger & debug.flagApp and debug.logger('processResponsePdu: sendPduHandle %s, request/response data mismatch' % sendPduHandle)
- cbFun(snmpEngine,
- origSendRequestHandle,
- 'badResponse', # errorIndication
- None,
- cbCtx)
+ cbFun(snmpEngine, origSendRequestHandle,
+ 'badResponse', None, cbCtx)
return
# User-side API assumes SMIv2
@@ -160,35 +118,18 @@ class CommandGenerator:
# 3.1.2
if v2c.apiPDU.getRequestID(PDU) != v2c.apiPDU.getRequestID(origPdu):
debug.logger & debug.flagApp and debug.logger('processResponsePdu: sendPduHandle %s, request-id/response-id mismatch' % sendPduHandle)
- cbFun(snmpEngine,
- origSendRequestHandle,
- 'badResponse', # errorIndication
- None,
- cbCtx)
+ cbFun(snmpEngine, origSendRequestHandle,
+ 'badResponse', None, cbCtx)
return
- cbFun(snmpEngine,
- origSendRequestHandle,
- None, # errorIndication
- PDU,
- cbCtx)
-
- def sendPdu(self,
- snmpEngine,
- targetName,
- contextEngineId,
- contextName,
- PDU,
- cbFun,
- cbCtx):
- ( transportDomain,
- transportAddress,
- timeout,
- retryCount,
- messageProcessingModel,
- securityModel,
- securityName,
- securityLevel ) = config.getTargetInfo(snmpEngine, targetName)
+ cbFun(snmpEngine, origSendRequestHandle, None, PDU, cbCtx)
+
+ def sendPdu(self, snmpEngine, targetName, contextEngineId,
+ contextName, PDU, cbFun, cbCtx):
+ (transportDomain, transportAddress, timeout,
+ retryCount, messageProcessingModel, securityModel,
+ securityName,
+ securityLevel) = config.getTargetInfo(snmpEngine, targetName)
# Convert timeout in seconds into timeout in timer ticks
timeoutInTicks = float(timeout)/100/snmpEngine.transportDispatcher.getTimerResolution()
@@ -213,39 +154,20 @@ class CommandGenerator:
# 3.1
sendPduHandle = snmpEngine.msgAndPduDsp.sendPdu(
- snmpEngine,
- transportDomain,
- transportAddress,
- messageProcessingModel,
- securityModel,
- securityName,
- securityLevel,
- contextEngineId,
- contextName,
- pduVersion,
- PDU,
- 1, # expectResponse
- timeoutInTicks,
- self.processResponsePdu,
+ snmpEngine, transportDomain, transportAddress,
+ messageProcessingModel, securityModel, securityName,
+ securityLevel, contextEngineId, contextName,
+ pduVersion, PDU, True, timeoutInTicks, self.processResponsePdu,
(sendRequestHandle, cbFun, cbCtx)
)
snmpEngine.transportDispatcher.jobStarted(id(self))
self.__pendingReqs[sendPduHandle] = (
- transportDomain,
- transportAddress,
- messageProcessingModel,
- securityModel,
- securityName,
- securityLevel,
- contextEngineId,
- contextName,
- pduVersion,
- origPDU,
- timeoutInTicks,
- retryCount,
- 0
+ transportDomain, transportAddress, messageProcessingModel,
+ securityModel, securityName, securityLevel, contextEngineId,
+ contextName, pduVersion, origPDU, timeoutInTicks,
+ retryCount, 0
)
debug.logger & debug.flagApp and debug.logger('sendPdu: sendPduHandle %s, timeout %d*10 ms/%d ticks, retry 0 of %d' % (sendPduHandle, timeout, timeoutInTicks, retryCount))
@@ -256,135 +178,77 @@ class CommandGenerator:
CommandGeneratorBase = CommandGenerator
class GetCommandGenerator(CommandGenerator):
- def processResponseVarBinds(self,
- snmpEngine,
- sendRequestHandle,
- errorIndication,
- PDU,
- cbCtx):
+ def processResponseVarBinds(self, snmpEngine, sendRequestHandle,
+ errorIndication, PDU, cbCtx):
cbFun, cbCtx = cbCtx
- cbFun(snmpEngine,
- sendRequestHandle,
- errorIndication,
+ cbFun(snmpEngine, sendRequestHandle, errorIndication,
PDU and v2c.apiPDU.getErrorStatus(PDU) or 0,
PDU and v2c.apiPDU.getErrorIndex(PDU, muteErrors=True) or 0,
- PDU and v2c.apiPDU.getVarBinds(PDU) or (),
- cbCtx)
-
- def sendVarBinds(self,
- snmpEngine,
- targetName,
- contextEngineId,
- contextName,
- varBinds,
- cbFun,
- cbCtx=None):
+ PDU and v2c.apiPDU.getVarBinds(PDU) or (), cbCtx)
+
+ def sendVarBinds(self, snmpEngine, targetName, contextEngineId,
+ contextName, varBinds, cbFun, cbCtx=None):
reqPDU = v2c.GetRequestPDU()
v2c.apiPDU.setDefaults(reqPDU)
v2c.apiPDU.setVarBinds(reqPDU, varBinds)
- return self.sendPdu(snmpEngine,
- targetName,
- contextEngineId,
- contextName,
- reqPDU,
- self.processResponseVarBinds,
+ return self.sendPdu(snmpEngine, targetName, contextEngineId,
+ contextName, reqPDU, self.processResponseVarBinds,
(cbFun, cbCtx))
class SetCommandGenerator(CommandGenerator):
- def processResponseVarBinds(self,
- snmpEngine,
- sendRequestHandle,
- errorIndication,
- PDU,
- cbCtx):
+ def processResponseVarBinds(self, snmpEngine, sendRequestHandle,
+ errorIndication, PDU, cbCtx):
cbFun, cbCtx = cbCtx
- cbFun(snmpEngine,
- sendRequestHandle,
- errorIndication,
+ cbFun(snmpEngine, sendRequestHandle, errorIndication,
PDU and v2c.apiPDU.getErrorStatus(PDU) or 0,
PDU and v2c.apiPDU.getErrorIndex(PDU, muteErrors=True) or 0,
- PDU and v2c.apiPDU.getVarBinds(PDU) or (),
- cbCtx)
-
- def sendVarBinds(self,
- snmpEngine,
- targetName,
- contextEngineId,
- contextName,
- varBinds,
- cbFun,
- cbCtx=None):
+ PDU and v2c.apiPDU.getVarBinds(PDU) or (), cbCtx)
+
+ def sendVarBinds(self, snmpEngine, targetName, contextEngineId,
+ contextName, varBinds, cbFun, cbCtx=None):
reqPDU = v2c.SetRequestPDU()
v2c.apiPDU.setDefaults(reqPDU)
v2c.apiPDU.setVarBinds(reqPDU, varBinds)
- return self.sendPdu(snmpEngine,
- targetName,
- contextEngineId,
- contextName,
- reqPDU,
- self.processResponseVarBinds,
- (cbFun, cbCtx))
+ return self.sendPdu(snmpEngine, targetName, contextEngineId,
+ contextName, reqPDU,
+ self.processResponseVarBinds, (cbFun, cbCtx))
class NextCommandGeneratorSingleRun(CommandGenerator):
- def processResponseVarBinds(self,
- snmpEngine,
- sendRequestHandle,
- errorIndication,
- PDU,
- cbCtx):
+ def processResponseVarBinds(self, snmpEngine, sendRequestHandle,
+ errorIndication, PDU, cbCtx):
targetName, contextEngineId, contextName, reqPDU, cbFun, cbCtx = cbCtx
- cbFun(snmpEngine,
- sendRequestHandle,
- errorIndication,
+ cbFun(snmpEngine, sendRequestHandle, errorIndication,
PDU and v2c.apiPDU.getErrorStatus(PDU) or 0,
PDU and v2c.apiPDU.getErrorIndex(PDU, muteErrors=True) or 0,
- PDU and v2c.apiPDU.getVarBinds(PDU) or (),
- cbCtx)
-
- def sendVarBinds(self,
- snmpEngine,
- targetName,
- contextEngineId,
- contextName,
- varBinds,
- cbFun,
- cbCtx=None):
+ PDU and v2c.apiPDU.getVarBinds(PDU) or (), cbCtx)
+
+ def sendVarBinds(self, snmpEngine, targetName, contextEngineId,
+ contextName, varBinds, cbFun, cbCtx=None):
reqPDU = v2c.GetNextRequestPDU()
v2c.apiPDU.setDefaults(reqPDU)
v2c.apiPDU.setVarBinds(reqPDU, varBinds)
- return self.sendPdu(snmpEngine,
- targetName,
- contextEngineId,
- contextName,
- reqPDU,
- self.processResponseVarBinds,
+ return self.sendPdu(snmpEngine, targetName, contextEngineId,
+ contextName, reqPDU, self.processResponseVarBinds,
(targetName, contextEngineId, contextName,
reqPDU, cbFun, cbCtx))
class NextCommandGenerator(NextCommandGeneratorSingleRun):
- def processResponseVarBinds(self,
- snmpEngine,
- sendRequestHandle,
- errorIndication,
- PDU,
- cbCtx):
+ def processResponseVarBinds(self, snmpEngine, sendRequestHandle,
+ errorIndication, PDU, cbCtx):
targetName, contextEngineId, contextName, reqPDU, cbFun, cbCtx = cbCtx
if errorIndication:
- cbFun(snmpEngine,
- sendRequestHandle,
- errorIndication,
- 0, 0, (),
- cbCtx)
+ cbFun(snmpEngine, sendRequestHandle, errorIndication,
+ 0, 0, (), cbCtx)
return
varBindTable = v2c.apiPDU.getVarBindTable(reqPDU, PDU)
@@ -398,13 +262,10 @@ class NextCommandGenerator(NextCommandGeneratorSingleRun):
varBindTable[-1], v2c.apiPDU.getVarBinds(reqPDU)
)
- if not cbFun(snmpEngine,
- sendRequestHandle,
- errorIndication,
+ if not cbFun(snmpEngine, sendRequestHandle, errorIndication,
v2c.apiPDU.getErrorStatus(PDU),
v2c.apiPDU.getErrorIndex(PDU, muteErrors=True),
- varBindTable,
- cbCtx):
+ varBindTable, cbCtx):
debug.logger & debug.flagApp and debug.logger('processResponseVarBinds: sendRequestHandle %s, app says to stop walking' % sendRequestHandle)
return # app says enough
@@ -415,11 +276,8 @@ class NextCommandGenerator(NextCommandGeneratorSingleRun):
v2c.apiPDU.setVarBinds(reqPDU, varBinds)
try:
- self.sendPdu(snmpEngine,
- targetName,
- contextEngineId,
- contextName,
- reqPDU,
+ self.sendPdu(snmpEngine, targetName, contextEngineId,
+ contextName, reqPDU,
self.processResponseVarBinds,
(targetName, contextEngineId, contextName,
reqPDU, cbFun, cbCtx))
@@ -427,39 +285,24 @@ class NextCommandGenerator(NextCommandGeneratorSingleRun):
except StatusInformation:
statusInformation = sys.exc_info()[1]
debug.logger & debug.flagApp and debug.logger('sendVarBinds: sendPduHandle %s: sendPdu() failed with %r' % (sendRequestHandle, statusInformation))
- cbFun(snmpEngine,
- sendRequestHandle,
+ cbFun(snmpEngine, sendRequestHandle,
statusInformation['errorIndication'],
0, 0, (), cbCtx)
class BulkCommandGeneratorSingleRun(CommandGenerator):
- def processResponseVarBinds(self,
- snmpEngine,
- sendRequestHandle,
- errorIndication,
- PDU,
- cbCtx):
- targetName, nonRepeaters, maxRepetitions, \
- contextEngineId, contextName, reqPDU, cbFun, cbCtx = cbCtx
-
- cbFun(snmpEngine,
- sendRequestHandle,
- errorIndication,
+ def processResponseVarBinds(self, snmpEngine, sendRequestHandle,
+ errorIndication, PDU, cbCtx):
+ (targetName, nonRepeaters, maxRepetitions,
+ contextEngineId, contextName, reqPDU, cbFun, cbCtx) = cbCtx
+
+ cbFun(snmpEngine, sendRequestHandle, errorIndication,
PDU and v2c.apiPDU.getErrorStatus(PDU) or 0,
PDU and v2c.apiPDU.getErrorIndex(PDU, muteErrors=True) or 0,
- PDU and v2c.apiPDU.getVarBinds(PDU) or (),
- cbCtx)
-
- def sendVarBinds(self,
- snmpEngine,
- targetName,
- contextEngineId,
- contextName,
- nonRepeaters,
- maxRepetitions,
- varBinds,
- cbFun,
- cbCtx=None):
+ PDU and v2c.apiPDU.getVarBinds(PDU) or (), cbCtx)
+
+ def sendVarBinds(self, snmpEngine, targetName, contextEngineId,
+ contextName, nonRepeaters, maxRepetitions,
+ varBinds, cbFun, cbCtx=None):
reqPDU = v2c.GetBulkRequestPDU()
v2c.apiBulkPDU.setDefaults(reqPDU)
@@ -468,32 +311,22 @@ class BulkCommandGeneratorSingleRun(CommandGenerator):
v2c.apiBulkPDU.setVarBinds(reqPDU, varBinds)
- return self.sendPdu(snmpEngine,
- targetName,
- contextEngineId,
- contextName,
- reqPDU,
+ return self.sendPdu(snmpEngine, targetName, contextEngineId,
+ contextName, reqPDU,
self.processResponseVarBinds,
(targetName, nonRepeaters, maxRepetitions,
contextEngineId, contextName, reqPDU,
cbFun, cbCtx))
class BulkCommandGenerator(BulkCommandGeneratorSingleRun):
- def processResponseVarBinds(self,
- snmpEngine,
- sendRequestHandle,
- errorIndication,
- PDU,
- cbCtx):
- targetName, nonRepeaters, maxRepetitions, \
- contextEngineId, contextName, reqPDU, cbFun, cbCtx = cbCtx
+ def processResponseVarBinds(self, snmpEngine, sendRequestHandle,
+ errorIndication, PDU, cbCtx):
+ (targetName, nonRepeaters, maxRepetitions,
+ contextEngineId, contextName, reqPDU, cbFun, cbCtx) = cbCtx
if errorIndication:
- cbFun(snmpEngine,
- sendRequestHandle,
- errorIndication,
- 0, 0, (),
- cbCtx)
+ cbFun(snmpEngine, sendRequestHandle, errorIndication,
+ 0, 0, (), cbCtx)
return
varBindTable = v2c.apiBulkPDU.getVarBindTable(reqPDU, PDU)
@@ -510,9 +343,7 @@ class BulkCommandGenerator(BulkCommandGeneratorSingleRun):
if nonRepeaters:
varBinds = v2c.apiBulkPDU.getVarBinds(reqPDU)[:int(nonRepeaters)] + varBinds[int(nonRepeaters):]
- if not cbFun(snmpEngine,
- sendRequestHandle,
- errorIndication,
+ if not cbFun(snmpEngine, sendRequestHandle, errorIndication,
v2c.apiBulkPDU.getErrorStatus(PDU),
v2c.apiBulkPDU.getErrorIndex(PDU, muteErrors=True),
varBindTable, cbCtx):
@@ -527,11 +358,8 @@ class BulkCommandGenerator(BulkCommandGeneratorSingleRun):
try:
- self.sendPdu(snmpEngine,
- targetName,
- contextEngineId,
- contextName,
- reqPDU,
+ self.sendPdu(snmpEngine, targetName, contextEngineId,
+ contextName, reqPDU,
self.processResponseVarBinds,
(targetName, nonRepeaters, maxRepetitions,
contextEngineId, contextName, reqPDU, cbFun, cbCtx))
@@ -539,65 +367,31 @@ class BulkCommandGenerator(BulkCommandGeneratorSingleRun):
except StatusInformation:
statusInformation = sys.exc_info()[1]
debug.logger & debug.flagApp and debug.logger('processResponseVarBinds: sendPduHandle %s: _sendPdu() failed with %r' % (sendRequestHandle, statusInformation))
- cbFun(snmpEngine,
- sendRequestHandle,
- statusInformation['errorIndication'],
- 0, 0, (), cbCtx)
+ cbFun(snmpEngine, sendRequestHandle,
+ statusInformation['errorIndication'], 0, 0, (), cbCtx)
#
# Obsolete, compatibility interfaces.
#
-def __sendReqCbFun(snmpEngine,
- sendRequestHandle,
- errorIndication,
- errorStatus,
- errorIndex,
- varBinds,
- cbCtx):
+def __sendReqCbFun(snmpEngine, sendRequestHandle, errorIndication,
+ errorStatus, errorIndex, varBinds, cbCtx):
cbFun, cbCtx = cbCtx
- return cbFun(sendRequestHandle,
- errorIndication,
- errorStatus,
- errorIndex,
- varBinds,
- cbCtx)
-
-def _sendReq(self,
- snmpEngine,
- targetName,
- varBinds,
- cbFun,
- cbCtx=None,
- contextEngineId=None,
- contextName=''):
- return self.sendVarBinds(snmpEngine,
- targetName,
- contextEngineId,
- contextName,
- varBinds,
- __sendReqCbFun,
+ return cbFun(sendRequestHandle, errorIndication, errorStatus,
+ errorIndex, varBinds, cbCtx)
+
+def _sendReq(self, snmpEngine, targetName, varBinds, cbFun,
+ cbCtx=None, contextEngineId=None, contextName=''):
+ return self.sendVarBinds(snmpEngine, targetName, contextEngineId,
+ contextName, varBinds, __sendReqCbFun,
(cbFun, cbCtx))
-def _sendBulkReq(self,
- snmpEngine,
- targetName,
- nonRepeaters,
- maxRepetitions,
- varBinds,
- cbFun,
- cbCtx=None,
- contextEngineId=None,
+def _sendBulkReq(self, snmpEngine, targetName, nonRepeaters, maxRepetitions,
+ varBinds, cbFun, cbCtx=None, contextEngineId=None,
contextName=''):
- return self.sendVarBinds(snmpEngine,
- targetName,
- contextEngineId,
- contextName,
- nonRepeaters,
- maxRepetitions,
- varBinds,
- __sendReqCbFun,
- (cbFun, cbCtx))
+ return self.sendVarBinds(snmpEngine, targetName, contextEngineId,
+ contextName, nonRepeaters, maxRepetitions,
+ varBinds, __sendReqCbFun, (cbFun, cbCtx))
# install compatibility wrappers
GetCommandGenerator.sendReq = _sendReq
diff --git a/pysnmp/entity/rfc3413/cmdrsp.py b/pysnmp/entity/rfc3413/cmdrsp.py
index dfe9ec13..2b30e8e8 100644
--- a/pysnmp/entity/rfc3413/cmdrsp.py
+++ b/pysnmp/entity/rfc3413/cmdrsp.py
@@ -136,31 +136,31 @@ class CommandResponderBase:
# PDU-level SMI errors
except pysnmp.smi.error.NoAccessError:
- errorStatus, errorIndex = 'noAccess', sys.exc_info()[1]['idx']+1
+ errorStatus, errorIndex = 'noAccess', sys.exc_info()[1]['idx'] + 1
except pysnmp.smi.error.WrongTypeError:
- errorStatus, errorIndex = 'wrongType', sys.exc_info()[1]['idx']+1
+ errorStatus, errorIndex = 'wrongType', sys.exc_info()[1]['idx'] + 1
except pysnmp.smi.error.WrongLengthError:
- errorStatus, errorIndex = 'wrongLength', sys.exc_info()[1]['idx']+1
+ errorStatus, errorIndex = 'wrongLength', sys.exc_info()[1]['idx'] + 1
except pysnmp.smi.error.WrongEncodingError:
- errorStatus, errorIndex='wrongEncoding', sys.exc_info()[1]['idx']+1
+ errorStatus, errorIndex = 'wrongEncoding', sys.exc_info()[1]['idx'] + 1
except pysnmp.smi.error.WrongValueError:
- errorStatus, errorIndex = 'wrongValue', sys.exc_info()[1]['idx']+1
+ errorStatus, errorIndex = 'wrongValue', sys.exc_info()[1]['idx'] + 1
except pysnmp.smi.error.NoCreationError:
- errorStatus, errorIndex = 'noCreation', sys.exc_info()[1]['idx']+1
+ errorStatus, errorIndex = 'noCreation', sys.exc_info()[1]['idx'] + 1
except pysnmp.smi.error.InconsistentValueError:
- errorStatus, errorIndex = 'inconsistentValue', sys.exc_info()[1]['idx']+1
+ errorStatus, errorIndex = 'inconsistentValue', sys.exc_info()[1]['idx'] + 1
except pysnmp.smi.error.ResourceUnavailableError:
- errorStatus, errorIndex = 'resourceUnavailable', sys.exc_info()[1]['idx']+1
+ errorStatus, errorIndex = 'resourceUnavailable', sys.exc_info()[1]['idx'] + 1
except pysnmp.smi.error.CommitFailedError:
- errorStatus, errorIndex = 'commitFailed', sys.exc_info()[1]['idx']+1
+ errorStatus, errorIndex = 'commitFailed', sys.exc_info()[1]['idx'] + 1
except pysnmp.smi.error.UndoFailedError:
- errorStatus, errorIndex = 'undoFailed', sys.exc_info()[1]['idx']+1
+ errorStatus, errorIndex = 'undoFailed', sys.exc_info()[1]['idx'] + 1
except pysnmp.smi.error.AuthorizationError:
- errorStatus, errorIndex = 'authorizationError', sys.exc_info()[1]['idx']+1
+ errorStatus, errorIndex = 'authorizationError', sys.exc_info()[1]['idx'] + 1
except pysnmp.smi.error.NotWritableError:
- errorStatus, errorIndex = 'notWritable', sys.exc_info()[1]['idx']+1
+ errorStatus, errorIndex = 'notWritable', sys.exc_info()[1]['idx'] + 1
except pysnmp.smi.error.InconsistentNameError:
- errorStatus, errorIndex = 'inconsistentName', sys.exc_info()[1]['idx']+1
+ errorStatus, errorIndex = 'inconsistentName', sys.exc_info()[1]['idx'] + 1
except pysnmp.smi.error.SmiError:
errorStatus, errorIndex = 'genErr', len(varBinds) and 1 or 0
except pysnmp.error.PySnmpError:
diff --git a/pysnmp/entity/rfc3413/config.py b/pysnmp/entity/rfc3413/config.py
index 8add3901..5e0ccdb1 100644
--- a/pysnmp/entity/rfc3413/config.py
+++ b/pysnmp/entity/rfc3413/config.py
@@ -11,7 +11,7 @@ def getTargetAddr(snmpEngine, snmpTargetAddrName):
cache = snmpEngine.getUserContext('getTargetAddr')
if cache is None:
- cache = { 'id': -1 }
+ cache = {'id': -1}
snmpEngine.setUserContext(getTargetAddr=cache)
if cache['id'] != snmpTargetAddrEntry.branchVersionId:
@@ -94,7 +94,7 @@ def getTargetParams(snmpEngine, paramsName):
cache = snmpEngine.getUserContext('getTargetParams')
if cache is None:
- cache = { 'id': -1 }
+ cache = {'id': -1}
snmpEngine.setUserContext(getTargetParams=cache)
if cache['id'] != snmpTargetParamsEntry.branchVersionId:
@@ -225,7 +225,7 @@ def getTargetNames(snmpEngine, tag):
'snmpTargetAddrTagList'
)
targetNames = []
- mibNode = snmpTargetAddrTagList
+ mibNode = snmpTargetAddrTagList
while True:
try:
mibNode = snmpTargetAddrTagList.getNextNode(mibNode.name)
diff --git a/pysnmp/entity/rfc3413/context.py b/pysnmp/entity/rfc3413/context.py
index 9a2f12fd..565bb3c2 100644
--- a/pysnmp/entity/rfc3413/context.py
+++ b/pysnmp/entity/rfc3413/context.py
@@ -6,7 +6,7 @@ from pysnmp import debug
class SnmpContext:
def __init__(self, snmpEngine, contextEngineId=None):
- snmpEngineId,= snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineID')
+ snmpEngineId, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineID')
if contextEngineId is None:
# Default to local snmpEngineId
self.contextEngineId = snmpEngineId.syntax
diff --git a/pysnmp/entity/rfc3413/mibvar.py b/pysnmp/entity/rfc3413/mibvar.py
index 969d7ab7..65b4653c 100644
--- a/pysnmp/entity/rfc3413/mibvar.py
+++ b/pysnmp/entity/rfc3413/mibvar.py
@@ -10,7 +10,7 @@ from pysnmp.smi.error import NoSuchObjectError
def mibNameToOid(mibView, name):
if isinstance(name[0], tuple):
- f = lambda x='',y='': (x,y)
+ f = lambda x='', y='': (x, y)
modName, symName = f(*name[0])
if modName: # load module if needed
mibView.mibBuilder.loadModules(modName)
diff --git a/pysnmp/entity/rfc3413/ntforg.py b/pysnmp/entity/rfc3413/ntforg.py
index 42274069..a57397fb 100644
--- a/pysnmp/entity/rfc3413/ntforg.py
+++ b/pysnmp/entity/rfc3413/ntforg.py
@@ -184,7 +184,7 @@ class NotificationOriginator:
debug.logger & debug.flagApp and debug.logger('sendVarBinds: notificationHandle %s, notifyTag %s, notifyType %s' % (notificationHandle, notifyTag, notifyType))
- varBinds = [(v2c.ObjectIdentifier(x),y) for x,y in varBinds]
+ varBinds = [(v2c.ObjectIdentifier(x), y) for x, y in varBinds]
# 3.3.2 & 3.3.3
snmpTrapOID, sysUpTime = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', 'snmpTrapOID', 'sysUpTime')
diff --git a/pysnmp/entity/rfc3413/oneliner/cmdgen.py b/pysnmp/entity/rfc3413/oneliner/cmdgen.py
index 63ea6976..827ca08b 100644
--- a/pysnmp/entity/rfc3413/oneliner/cmdgen.py
+++ b/pysnmp/entity/rfc3413/oneliner/cmdgen.py
@@ -31,25 +31,17 @@ class AsynCommandGenerator:
self.lcd.unconfigure(self.snmpEngine)
def cfgCmdGen(self, authData, transportTarget):
- return self.lcd.configure(
- self.snmpEngine, authData, transportTarget
- )
+ return self.lcd.configure(self.snmpEngine, authData, transportTarget)
def uncfgCmdGen(self, authData=None):
- return self.lcd.unconfigure(
- self.snmpEngine, authData
- )
+ return self.lcd.unconfigure(self.snmpEngine, authData)
# compatibility stub
def makeReadVarBinds(self, varNames):
- return self.makeVarBinds(
- [ (x, self._null) for x in varNames ]
- )
+ return self.makeVarBinds([(x, self._null) for x in varNames])
def makeVarBinds(self, varBinds):
- return self.vbProcessor.makeVarBinds(
- self.snmpEngine, varBinds
- )
+ return self.vbProcessor.makeVarBinds(self.snmpEngine, varBinds)
def unmakeVarBinds(self, varBinds, lookupNames, lookupValues):
return self.vbProcessor.unmakeVarBinds(
@@ -73,8 +65,7 @@ class AsynCommandGenerator:
contextName = authData.contextName
return getCmd(
- self.snmpEngine,
- authData, transportTarget,
+ self.snmpEngine, authData, transportTarget,
ContextData(contextEngineId, contextName),
*[(x, self._null) for x in varNames],
**dict(cbFun=__cbFun, cbCtx=cbInfo,
@@ -101,10 +92,8 @@ class AsynCommandGenerator:
return setCmd(
- self.snmpEngine,
- authData, transportTarget,
- ContextData(contextEngineId, contextName),
- *varBinds,
+ self.snmpEngine, authData, transportTarget,
+ ContextData(contextEngineId, contextName), *varBinds,
**dict(cbFun=__cbFun, cbCtx=cbInfo,
lookupMib=lookupNames or lookupValues)
)
@@ -128,8 +117,7 @@ class AsynCommandGenerator:
contextName = authData.contextName
return nextCmd(
- self.snmpEngine,
- authData, transportTarget,
+ self.snmpEngine, authData, transportTarget,
ContextData(contextEngineId, contextName),
*[(x, self._null) for x in varNames],
**dict(cbFun=__cbFun, cbCtx=cbInfo,
@@ -156,8 +144,7 @@ class AsynCommandGenerator:
contextName = authData.contextName
return bulkCmd(
- self.snmpEngine,
- authData, transportTarget,
+ self.snmpEngine, authData, transportTarget,
ContextData(contextEngineId, contextName),
nonRepeaters, maxRepetitions,
*[(x, self._null) for x in varNames],
@@ -185,7 +172,7 @@ class CommandGenerator:
in sync.getCmd(self.snmpEngine, authData, transportTarget,
ContextData(kwargs.get('contextEngineId'),
kwargs.get('contextName', null)),
- *[ (x, self._null) for x in varNames ],
+ *[(x, self._null) for x in varNames],
**kwargs):
break
return errorIndication, errorStatus, errorIndex, varBinds
@@ -223,7 +210,7 @@ class CommandGenerator:
in sync.nextCmd(self.snmpEngine, authData, transportTarget,
ContextData(kwargs.get('contextEngineId'),
kwargs.get('contextName', null)),
- *[ (x, self._null) for x in varNames ],
+ *[(x, self._null) for x in varNames],
**kwargs):
if errorIndication or errorStatus:
return errorIndication, errorStatus, errorIndex, varBinds
@@ -250,7 +237,7 @@ class CommandGenerator:
ContextData(kwargs.get('contextEngineId'),
kwargs.get('contextName', null)),
nonRepeaters, maxRepetitions,
- *[ (x, self._null) for x in varNames ],
+ *[(x, self._null) for x in varNames],
**kwargs):
if errorIndication or errorStatus:
return errorIndication, errorStatus, errorIndex, varBinds