summaryrefslogtreecommitdiff
path: root/pysnmp
diff options
context:
space:
mode:
authorIlya Etingof <etingof@gmail.com>2017-05-27 09:01:56 +0200
committerIlya Etingof <etingof@gmail.com>2017-05-27 09:01:56 +0200
commitc196de621f8e88faa7b8b9fe1ec43cfdd9687576 (patch)
tree9f7bde8874571d9c3d1bf9bd6b703e55301a3298 /pysnmp
parent72759c534ce3546c1a8f50321d29cf1d587ce7df (diff)
downloadpysnmp-git-c196de621f8e88faa7b8b9fe1ec43cfdd9687576.tar.gz
minor pep8 improvements
Diffstat (limited to 'pysnmp')
-rw-r--r--pysnmp/carrier/asyncore/dgram/base.py4
-rw-r--r--pysnmp/carrier/asyncore/dgram/udp6.py4
-rw-r--r--pysnmp/entity/engine.py9
-rw-r--r--pysnmp/entity/observer.py6
-rw-r--r--pysnmp/entity/rfc3413/cmdgen.py22
-rw-r--r--pysnmp/entity/rfc3413/cmdrsp.py16
-rw-r--r--pysnmp/entity/rfc3413/oneliner/cmdgen.py68
-rw-r--r--pysnmp/entity/rfc3413/oneliner/ntforg.py26
-rw-r--r--pysnmp/proto/mpmod/rfc2576.py22
-rw-r--r--pysnmp/proto/mpmod/rfc3412.py28
-rw-r--r--pysnmp/proto/rfc3412.py6
-rw-r--r--pysnmp/proto/secmod/rfc3414/auth/hmacmd5.py8
-rw-r--r--pysnmp/proto/secmod/rfc3414/auth/hmacsha.py8
-rw-r--r--pysnmp/proto/secmod/rfc3414/priv/des.py2
-rw-r--r--pysnmp/proto/secmod/rfc3414/service.py34
15 files changed, 130 insertions, 133 deletions
diff --git a/pysnmp/carrier/asyncore/dgram/base.py b/pysnmp/carrier/asyncore/dgram/base.py
index 0c1bfddb..428754cb 100644
--- a/pysnmp/carrier/asyncore/dgram/base.py
+++ b/pysnmp/carrier/asyncore/dgram/base.py
@@ -68,8 +68,8 @@ class DgramSocketTransport(AbstractSocketTransport):
return self
def enablePktInfo(self, flag=1):
- if not hasattr(self.socket, 'sendmsg') or \
- not hasattr(self.socket, 'recvmsg'):
+ if (not hasattr(self.socket, 'sendmsg') or
+ not hasattr(self.socket, 'recvmsg')):
raise error.CarrierError('sendmsg()/recvmsg() interface is not supported by this OS and/or Python version')
try:
diff --git a/pysnmp/carrier/asyncore/dgram/udp6.py b/pysnmp/carrier/asyncore/dgram/udp6.py
index 82beb646..cf11daa8 100644
--- a/pysnmp/carrier/asyncore/dgram/udp6.py
+++ b/pysnmp/carrier/asyncore/dgram/udp6.py
@@ -30,8 +30,8 @@ class Udp6SocketTransport(DgramSocketTransport):
ta = self.addressType((transportAddress[0],
transportAddress[1], 0, 0))
- if isinstance(transportAddress, self.addressType) and \
- transportAddress.getLocalAddress():
+ if (isinstance(transportAddress, self.addressType) and
+ transportAddress.getLocalAddress()):
return ta.setLocalAddress(transportAddress.getLocalAddress())
else:
return ta.setLocalAddress(self.getLocalAddress())
diff --git a/pysnmp/entity/engine.py b/pysnmp/entity/engine.py
index 5b89882a..b480de17 100644
--- a/pysnmp/entity/engine.py
+++ b/pysnmp/entity/engine.py
@@ -9,11 +9,9 @@ import sys
import tempfile
from pyasn1.compat.octets import str2octs
from pysnmp.proto.rfc3412 import MsgAndPduDispatcher
-from pysnmp.proto.mpmod.rfc2576 import SnmpV1MessageProcessingModel, \
- SnmpV2cMessageProcessingModel
+from pysnmp.proto.mpmod.rfc2576 import SnmpV1MessageProcessingModel, SnmpV2cMessageProcessingModel
from pysnmp.proto.mpmod.rfc3412 import SnmpV3MessageProcessingModel
-from pysnmp.proto.secmod.rfc2576 import SnmpV1SecurityModel, \
- SnmpV2cSecurityModel
+from pysnmp.proto.secmod.rfc2576 import SnmpV1SecurityModel, SnmpV2cSecurityModel
from pysnmp.proto.secmod.rfc3414 import SnmpUSMSecurityModel
from pysnmp.proto.acmod import rfc3415, void
from pysnmp.entity import observer
@@ -143,8 +141,7 @@ class SnmpEngine(object):
'SnmpEngine: stored SNMP Engine Boots: %s' % snmpEngineBoots.syntax.prettyPrint())
def __repr__(self):
- return '%s(snmpEngineID=%r)' % \
- (self.__class__.__name__, self.snmpEngineID)
+ return '%s(snmpEngineID=%r)' % (self.__class__.__name__, self.snmpEngineID)
# Transport dispatcher bindings
diff --git a/pysnmp/entity/observer.py b/pysnmp/entity/observer.py
index f3ff3d6e..a5d727cb 100644
--- a/pysnmp/entity/observer.py
+++ b/pysnmp/entity/observer.py
@@ -12,9 +12,9 @@ class MetaObserver(object):
working details to pysnmp applications. These details are
basically local scope variables at a fixed point of execution.
- Two modes of operations are offered(object):
- 1. App can request an execution point context by execution point ID.
- 2. App can register its callback function (and context) to be invoked
+ Two modes of operations are offered:
+ 1. Consumer: app can request an execution point context by execution point ID.
+ 2. Provider: app can register its callback function (and context) to be invoked
once execution reaches specified point. All local scope variables
will be passed to the callback as in #1.
diff --git a/pysnmp/entity/rfc3413/cmdgen.py b/pysnmp/entity/rfc3413/cmdgen.py
index 5fe0462a..d4f108a1 100644
--- a/pysnmp/entity/rfc3413/cmdgen.py
+++ b/pysnmp/entity/rfc3413/cmdgen.py
@@ -71,11 +71,11 @@ class CommandGenerator(object):
'processResponsePdu: sendPduHandle %s, statusInformation %s' % (sendPduHandle, statusInformation))
errorIndication = statusInformation['errorIndication']
# SNMP engine discovery will take extra retries, allow that
- if errorIndication in (errind.notInTimeWindow,
- errind.unknownEngineID) and \
- origRetries == origRetryCount + 2 or \
- errorIndication not in (errind.notInTimeWindow, errind.unknownEngineID) and \
- origRetries == origRetryCount:
+ if (errorIndication in (errind.notInTimeWindow,
+ errind.unknownEngineID) and
+ origRetries == origRetryCount + 2 or
+ errorIndication not in (errind.notInTimeWindow, errind.unknownEngineID) and
+ origRetries == origRetryCount):
debug.logger & debug.flagApp and debug.logger(
'processResponsePdu: sendPduHandle %s, retry count %d exceeded' % (sendPduHandle, origRetries))
cbFun(snmpEngine, origSendRequestHandle,
@@ -111,12 +111,12 @@ class CommandGenerator(object):
None, cbCtx)
return
- if origMessageProcessingModel != messageProcessingModel or \
- origSecurityModel != securityModel or \
- origSecurityName != origSecurityName or \
- origContextEngineId and origContextEngineId != contextEngineId or \
- origContextName and origContextName != contextName or \
- origPduVersion != pduVersion:
+ if (origMessageProcessingModel != messageProcessingModel or
+ origSecurityModel != securityModel or
+ origSecurityName != origSecurityName or
+ origContextEngineId and origContextEngineId != contextEngineId or
+ origContextName and origContextName != contextName or
+ origPduVersion != pduVersion):
debug.logger & debug.flagApp and debug.logger(
'processResponsePdu: sendPduHandle %s, request/response data mismatch' % sendPduHandle)
diff --git a/pysnmp/entity/rfc3413/cmdrsp.py b/pysnmp/entity/rfc3413/cmdrsp.py
index 344b7c4f..a2c54303 100644
--- a/pysnmp/entity/rfc3413/cmdrsp.py
+++ b/pysnmp/entity/rfc3413/cmdrsp.py
@@ -110,8 +110,8 @@ class CommandResponderBase(object):
origPdu = None
# 3.2.1
- if PDU.tagSet not in rfc3411.readClassPDUs and \
- PDU.tagSet not in rfc3411.writeClassPDUs:
+ if (PDU.tagSet not in rfc3411.readClassPDUs and
+ PDU.tagSet not in rfc3411.writeClassPDUs):
raise error.ProtocolError('Unexpected PDU class %s' % PDU.tagSet)
# 3.2.2 --> no-op
@@ -207,9 +207,9 @@ class CommandResponderBase(object):
'__verifyAccess: name %s, statusInformation %s' % (name, statusInformation))
errorIndication = statusInformation['errorIndication']
# 3.2.5...
- if errorIndication == errind.noSuchView or \
- errorIndication == errind.noAccessEntry or \
- errorIndication == errind.noGroupName:
+ if (errorIndication == errind.noSuchView or
+ errorIndication == errind.noAccessEntry or
+ errorIndication == errind.noGroupName):
raise pysnmp.smi.error.AuthorizationError(name=name, idx=idx)
elif errorIndication == errind.otherError:
raise pysnmp.smi.error.GenError(name=name, idx=idx)
@@ -227,9 +227,9 @@ class CommandResponderBase(object):
raise error.ProtocolError('Unknown ACM error %s' % errorIndication)
else:
# rfc2576: 4.1.2.1
- if securityModel == 1 and syntax is not None and \
- self._counter64Type == syntax.getTagSet() and \
- self._getNextRequestType == pduType:
+ if (securityModel == 1 and syntax is not None and
+ self._counter64Type == syntax.getTagSet() and
+ self._getNextRequestType == pduType):
# This will cause MibTree to skip this OID-value
raise pysnmp.smi.error.NoAccessError(name=name, idx=idx)
diff --git a/pysnmp/entity/rfc3413/oneliner/cmdgen.py b/pysnmp/entity/rfc3413/oneliner/cmdgen.py
index 71a7d79e..076d144b 100644
--- a/pysnmp/entity/rfc3413/oneliner/cmdgen.py
+++ b/pysnmp/entity/rfc3413/oneliner/cmdgen.py
@@ -173,14 +173,14 @@ class CommandGenerator(object):
if 'lookupValues' not in kwargs:
kwargs['lookupValues'] = False
errorIndication, errorStatus, errorIndex, varBinds = None, 0, 0, []
- for errorIndication, \
- errorStatus, errorIndex, \
- varBinds \
- in sync.getCmd(self.snmpEngine, authData, transportTarget,
- ContextData(kwargs.get('contextEngineId'),
- kwargs.get('contextName', null)),
- *[(x, self._null) for x in varNames],
- **kwargs):
+ for (errorIndication,
+ errorStatus,
+ errorIndex,
+ varBinds) in sync.getCmd(self.snmpEngine, authData, transportTarget,
+ ContextData(kwargs.get('contextEngineId'),
+ kwargs.get('contextName', null)),
+ *[(x, self._null) for x in varNames],
+ **kwargs):
break
return errorIndication, errorStatus, errorIndex, varBinds
@@ -190,14 +190,14 @@ class CommandGenerator(object):
if 'lookupValues' not in kwargs:
kwargs['lookupValues'] = False
errorIndication, errorStatus, errorIndex, rspVarBinds = None, 0, 0, []
- for errorIndication, \
- errorStatus, errorIndex, \
- rspVarBinds \
- in sync.setCmd(self.snmpEngine, authData, transportTarget,
- ContextData(kwargs.get('contextEngineId'),
- kwargs.get('contextName', null)),
- *varBinds,
- **kwargs):
+ for (errorIndication,
+ errorStatus,
+ errorIndex,
+ rspVarBinds) in sync.setCmd(self.snmpEngine, authData, transportTarget,
+ ContextData(kwargs.get('contextEngineId'),
+ kwargs.get('contextName', null)),
+ *varBinds,
+ **kwargs):
break
return errorIndication, errorStatus, errorIndex, rspVarBinds
@@ -211,14 +211,14 @@ class CommandGenerator(object):
kwargs['lexicographicMode'] = False
errorIndication, errorStatus, errorIndex = None, 0, 0
varBindTable = []
- for errorIndication, \
- errorStatus, errorIndex, \
- varBinds \
- in sync.nextCmd(self.snmpEngine, authData, transportTarget,
- ContextData(kwargs.get('contextEngineId'),
- kwargs.get('contextName', null)),
- *[(x, self._null) for x in varNames],
- **kwargs):
+ for (errorIndication,
+ errorStatus,
+ errorIndex,
+ varBinds) in sync.nextCmd(self.snmpEngine, authData, transportTarget,
+ ContextData(kwargs.get('contextEngineId'),
+ kwargs.get('contextName', null)),
+ *[(x, self._null) for x in varNames],
+ **kwargs):
if errorIndication or errorStatus:
return errorIndication, errorStatus, errorIndex, varBinds
@@ -236,16 +236,16 @@ class CommandGenerator(object):
kwargs['lexicographicMode'] = False
errorIndication, errorStatus, errorIndex = None, 0, 0
varBindTable = []
- for errorIndication, \
- errorStatus, errorIndex, \
- varBinds \
- in sync.bulkCmd(self.snmpEngine, authData,
- transportTarget,
- ContextData(kwargs.get('contextEngineId'),
- kwargs.get('contextName', null)),
- nonRepeaters, maxRepetitions,
- *[(x, self._null) for x in varNames],
- **kwargs):
+ for (errorIndication,
+ errorStatus,
+ errorIndex,
+ varBinds) in sync.bulkCmd(self.snmpEngine, authData,
+ transportTarget,
+ ContextData(kwargs.get('contextEngineId'),
+ kwargs.get('contextName', null)),
+ nonRepeaters, maxRepetitions,
+ *[(x, self._null) for x in varNames],
+ **kwargs):
if errorIndication or errorStatus:
return errorIndication, errorStatus, errorIndex, varBinds
diff --git a/pysnmp/entity/rfc3413/oneliner/ntforg.py b/pysnmp/entity/rfc3413/oneliner/ntforg.py
index 868e7708..b072206b 100644
--- a/pysnmp/entity/rfc3413/oneliner/ntforg.py
+++ b/pysnmp/entity/rfc3413/oneliner/ntforg.py
@@ -1,4 +1,4 @@
-#
+pysnmp/carrier/asyncore/dgram/base.py#
# This file is part of pysnmp software.
#
# Copyright (c) 2005-2017, Ilya Etingof <etingof@gmail.com>
@@ -163,19 +163,17 @@ class NotificationOriginator(object):
if not isinstance(notificationType, NotificationType):
notificationType = NotificationType(notificationType)
- errorIndication, errorStatus, errorIndex, rspVarBinds = None, 0, 0, []
- for errorIndication, \
- errorStatus, errorIndex, \
- rspVarBinds \
- in sync.sendNotification(self.snmpEngine, authData,
- transportTarget,
- ContextData(
- kwargs.get('contextEngineId'),
- kwargs.get('contextName', null)
- ),
- notifyType,
- notificationType.addVarBinds(*varBinds),
- **kwargs):
+
+ for (errorIndication,
+ errorStatus,
+ errorIndex,
+ rspVarBinds) in sync.sendNotification(self.snmpEngine, authData,
+ transportTarget,
+ ContextData(kwargs.get('contextEngineId'),
+ kwargs.get('contextName', null)),
+ notifyType,
+ notificationType.addVarBinds(*varBinds),
+ **kwargs):
if notifyType == 'inform':
return errorIndication, errorStatus, errorIndex, rspVarBinds
else:
diff --git a/pysnmp/proto/mpmod/rfc2576.py b/pysnmp/proto/mpmod/rfc2576.py
index 0200c825..43135d0e 100644
--- a/pysnmp/proto/mpmod/rfc2576.py
+++ b/pysnmp/proto/mpmod/rfc2576.py
@@ -266,13 +266,13 @@ class SnmpV1MessageProcessingModel(AbstractMessageProcessingModel):
# rfc2576: 5.2.1
snmpEngineMaxMessageSize, = mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineMaxMessageSize')
communityName = msg.getComponentByPosition(1)
- # transportDomain identifies local enpoint
+ # transportDomain identifies local endpoint
securityParameters = (communityName, (transportDomain, transportAddress))
messageProcessingModel = int(msg.getComponentByPosition(0))
securityModel = messageProcessingModel + 1
securityLevel = 1
- # rfc3412: 7.2.4 -- 7.2.5 -> noop
+ # rfc3412: 7.2.4 -- 7.2.5 -> no-op
k = int(securityModel)
if k in snmpEngine.securityModels:
@@ -293,7 +293,7 @@ class SnmpV1MessageProcessingModel(AbstractMessageProcessingModel):
debug.logger & debug.flagMP and debug.logger(
'prepareDataElements: SM returned securityEngineId %r securityName %r' % (securityEngineId, securityName))
- # rfc3412: 7.2.6a --> noop
+ # rfc3412: 7.2.6a --> no-op
# rfc3412: 7.2.7
contextEngineId, contextName, pdu = scopedPDU
@@ -302,7 +302,7 @@ class SnmpV1MessageProcessingModel(AbstractMessageProcessingModel):
pduVersion = msgVersion
pduType = pdu.tagSet
- # rfc3412: 7.2.8, 7.2.9 -> noop
+ # rfc3412: 7.2.8, 7.2.9 -> no-op
# rfc3412: 7.2.10
if pduType in rfc3411.responseClassPDUs:
@@ -331,18 +331,18 @@ class SnmpV1MessageProcessingModel(AbstractMessageProcessingModel):
# no error by default
statusInformation = None
- # rfc3412: 7.2.11 -> noop
+ # rfc3412: 7.2.11 -> no-op
# rfc3412: 7.2.12
if pduType in rfc3411.responseClassPDUs:
- # rfc3412: 7.2.12a -> noop
+ # rfc3412: 7.2.12a -> no-op
# rfc3412: 7.2.12b
# noinspection PyUnboundLocalVariable
- if securityModel != cachedReqParams['securityModel'] or \
- securityName != cachedReqParams['securityName'] or \
- securityLevel != cachedReqParams['securityLevel'] or \
- contextEngineId != cachedReqParams['contextEngineId'] or \
- contextName != cachedReqParams['contextName']:
+ if (securityModel != cachedReqParams['securityModel'] or
+ securityName != cachedReqParams['securityName'] or
+ securityLevel != cachedReqParams['securityLevel'] or
+ contextEngineId != cachedReqParams['contextEngineId'] or
+ contextName != cachedReqParams['contextName']):
smHandler.releaseStateInformation(securityStateReference)
raise error.StatusInformation(errorIndication=errind.dataMismatch)
diff --git a/pysnmp/proto/mpmod/rfc3412.py b/pysnmp/proto/mpmod/rfc3412.py
index 0734c45b..8f333a44 100644
--- a/pysnmp/proto/mpmod/rfc3412.py
+++ b/pysnmp/proto/mpmod/rfc3412.py
@@ -309,9 +309,9 @@ class SnmpV3MessageProcessingModel(AbstractMessageProcessingModel):
pduType = pdu.tagSet
# 7.1.3b
- if pdu is None and not reportableFlag or \
- pduType is not None and \
- pduType not in rfc3411.confirmedClassPDUs:
+ if (pdu is None and not reportableFlag or
+ pduType is not None and
+ pduType not in rfc3411.confirmedClassPDUs):
raise error.StatusInformation(
errorIndication=errind.loopTerminated
)
@@ -523,8 +523,10 @@ class SnmpV3MessageProcessingModel(AbstractMessageProcessingModel):
# 7.2.6
smHandler = snmpEngine.securityModels[securityModel]
try:
- (securityEngineId, securityName,
- scopedPDU, maxSizeResponseScopedPDU,
+ (securityEngineId,
+ securityName,
+ scopedPDU,
+ maxSizeResponseScopedPDU,
securityStateReference) = smHandler.processIncomingMsg(
snmpEngine, messageProcessingModel, maxMessageSize,
securityParameters, securityModel, securityLevel,
@@ -631,8 +633,8 @@ class SnmpV3MessageProcessingModel(AbstractMessageProcessingModel):
pduType = pdu.tagSet
# 7.2.10
- if pduType in rfc3411.responseClassPDUs or \
- pduType in rfc3411.internalClassPDUs:
+ if (pduType in rfc3411.responseClassPDUs or
+ pduType in rfc3411.internalClassPDUs):
# 7.2.10a
try:
cachedReqParams = self._cache.popByMsgId(msgID)
@@ -695,15 +697,15 @@ class SnmpV3MessageProcessingModel(AbstractMessageProcessingModel):
# 7.2.12
if pduType in rfc3411.responseClassPDUs:
- # 7.2.12a -> noop
+ # 7.2.12a -> no-op
# 7.2.12b
# noinspection PyUnboundLocalVariable
- if securityModel != cachedReqParams['securityModel'] or \
- securityName != cachedReqParams['securityName'] or \
- securityLevel != cachedReqParams['securityLevel'] or \
- contextEngineId != cachedReqParams['contextEngineId'] or \
- contextName != cachedReqParams['contextName']:
+ if (securityModel != cachedReqParams['securityModel'] or
+ securityName != cachedReqParams['securityName'] or
+ securityLevel != cachedReqParams['securityLevel'] or
+ contextEngineId != cachedReqParams['contextEngineId'] or
+ contextName != cachedReqParams['contextName']):
smHandler.releaseStateInformation(securityStateReference)
raise error.StatusInformation(
errorIndication=errind.dataMismatch
diff --git a/pysnmp/proto/rfc3412.py b/pysnmp/proto/rfc3412.py
index 1a06dec4..30235a96 100644
--- a/pysnmp/proto/rfc3412.py
+++ b/pysnmp/proto/rfc3412.py
@@ -57,7 +57,7 @@ class MsgAndPduDispatcher(object):
# 4.3.1
def registerContextEngineId(self, contextEngineId, pduTypes, processPdu):
"""Register application with dispatcher"""
- # 4.3.2 -> noop
+ # 4.3.2 -> no-op
# 4.3.3
for pduType in pduTypes:
@@ -244,8 +244,8 @@ class MsgAndPduDispatcher(object):
# Handle oversized messages XXX transport constrains?
snmpEngineMaxMessageSize, = self.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB',
'snmpEngineMaxMessageSize')
- if snmpEngineMaxMessageSize.syntax and \
- len(outgoingMessage) > snmpEngineMaxMessageSize.syntax:
+ if (snmpEngineMaxMessageSize.syntax and
+ len(outgoingMessage) > snmpEngineMaxMessageSize.syntax):
snmpSilentDrops, = self.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', 'snmpSilentDrops')
snmpSilentDrops.syntax += 1
raise error.StatusInformation(errorIndication=errind.tooBig)
diff --git a/pysnmp/proto/secmod/rfc3414/auth/hmacmd5.py b/pysnmp/proto/secmod/rfc3414/auth/hmacmd5.py
index 329e4e71..35a95b32 100644
--- a/pysnmp/proto/secmod/rfc3414/auth/hmacmd5.py
+++ b/pysnmp/proto/secmod/rfc3414/auth/hmacmd5.py
@@ -49,14 +49,14 @@ class HmacMd5(base.AbstractAuthenticationService):
# 6.3.1.2a
extendedAuthKey = authKey.asNumbers() + _fortyEightZeros
- # 6.3.1.2b --> noop
+ # 6.3.1.2b --> no-op
# 6.3.1.2c
k1 = univ.OctetString(
map(lambda x, y: x ^ y, extendedAuthKey, self.__ipad)
)
- # 6.3.1.2d --> noop
+ # 6.3.1.2d --> no-op
# 6.3.1.2e
k2 = univ.OctetString(
@@ -94,14 +94,14 @@ class HmacMd5(base.AbstractAuthenticationService):
# 6.3.2.4a
extendedAuthKey = authKey.asNumbers() + _fortyEightZeros
- # 6.3.2.4b --> noop
+ # 6.3.2.4b --> no-op
# 6.3.2.4c
k1 = univ.OctetString(
map(lambda x, y: x ^ y, extendedAuthKey, self.__ipad)
)
- # 6.3.2.4d --> noop
+ # 6.3.2.4d --> no-op
# 6.3.2.4e
k2 = univ.OctetString(
diff --git a/pysnmp/proto/secmod/rfc3414/auth/hmacsha.py b/pysnmp/proto/secmod/rfc3414/auth/hmacsha.py
index 5463b04f..5bc3c457 100644
--- a/pysnmp/proto/secmod/rfc3414/auth/hmacsha.py
+++ b/pysnmp/proto/secmod/rfc3414/auth/hmacsha.py
@@ -48,14 +48,14 @@ class HmacSha(base.AbstractAuthenticationService):
# 7.3.1.2a
extendedAuthKey = authKey.asNumbers() + _fortyFourZeros
- # 7.3.1.2b -- noop
+ # 7.3.1.2b -- no-op
# 7.3.1.2c
k1 = univ.OctetString(
map(lambda x, y: x ^ y, extendedAuthKey, self.__ipad)
)
- # 7.3.1.2d -- noop
+ # 7.3.1.2d -- no-op
# 7.3.1.2e
k2 = univ.OctetString(
@@ -91,14 +91,14 @@ class HmacSha(base.AbstractAuthenticationService):
# 7.3.2.4a
extendedAuthKey = authKey.asNumbers() + _fortyFourZeros
- # 7.3.2.4b --> noop
+ # 7.3.2.4b --> no-op
# 7.3.2.4c
k1 = univ.OctetString(
map(lambda x, y: x ^ y, extendedAuthKey, self.__ipad)
)
- # 7.3.2.4d --> noop
+ # 7.3.2.4d --> no-op
# 7.3.2.4e
k2 = univ.OctetString(
diff --git a/pysnmp/proto/secmod/rfc3414/priv/des.py b/pysnmp/proto/secmod/rfc3414/priv/des.py
index 268b5e8d..57f47c33 100644
--- a/pysnmp/proto/secmod/rfc3414/priv/des.py
+++ b/pysnmp/proto/secmod/rfc3414/priv/des.py
@@ -121,7 +121,7 @@ class Des(base.AbstractEncryptionService):
errorIndication=errind.decryptionError
)
- # 8.3.2.2 noop
+ # 8.3.2.2 no-op
# 8.3.2.3
desKey, iv = self.__getDecryptionKey(decryptKey, salt)
diff --git a/pysnmp/proto/secmod/rfc3414/service.py b/pysnmp/proto/secmod/rfc3414/service.py
index 4b4213c6..eb030e2f 100644
--- a/pysnmp/proto/secmod/rfc3414/service.py
+++ b/pysnmp/proto/secmod/rfc3414/service.py
@@ -307,8 +307,8 @@ class SnmpUSMSecurityModel(AbstractSecurityModel):
# 3.1.2
if securityLevel == 3:
- if usmUserAuthProtocol == noauth.NoAuth.serviceID or \
- usmUserPrivProtocol == nopriv.NoPriv.serviceID:
+ if (usmUserAuthProtocol == noauth.NoAuth.serviceID or
+ usmUserPrivProtocol == nopriv.NoPriv.serviceID):
raise error.StatusInformation(
errorIndication=errind.unsupportedSecurityLevel
)
@@ -578,13 +578,13 @@ class SnmpUSMSecurityModel(AbstractSecurityModel):
snmpEngineID = mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineID')[0].syntax
# 3.2.3
- if msgAuthoritativeEngineId != snmpEngineID and \
- msgAuthoritativeEngineId not in self.__timeline:
- if msgAuthoritativeEngineId and \
- 4 < len(msgAuthoritativeEngineId) < 33:
+ if (msgAuthoritativeEngineId != snmpEngineID and
+ msgAuthoritativeEngineId not in self.__timeline):
+ if (msgAuthoritativeEngineId and
+ 4 < len(msgAuthoritativeEngineId) < 33):
# 3.2.3a - cloned user when request was sent
debug.logger & debug.flagSM and debug.logger(
- 'processIncomingMsg: unsynchronized securityEngineID %r' % (msgAuthoritativeEngineId,))
+ 'processIncomingMsg: non-synchronized securityEngineID %r' % (msgAuthoritativeEngineId,))
else:
# 3.2.3b
debug.logger & debug.flagSM and debug.logger(
@@ -833,9 +833,9 @@ class SnmpUSMSecurityModel(AbstractSecurityModel):
# 3.2.7a
if msgAuthoritativeEngineId == snmpEngineID:
- if snmpEngineBoots == 2147483647 or \
- snmpEngineBoots != msgAuthoritativeEngineBoots or \
- abs(idleTime + int(snmpEngineTime) - int(msgAuthoritativeEngineTime)) > 150:
+ if (snmpEngineBoots == 2147483647 or
+ snmpEngineBoots != msgAuthoritativeEngineBoots or
+ abs(idleTime + int(snmpEngineTime) - int(msgAuthoritativeEngineTime)) > 150):
usmStatsNotInTimeWindows, = mibBuilder.importSymbols(
'__SNMP-USER-BASED-SM-MIB', 'usmStatsNotInTimeWindows')
usmStatsNotInTimeWindows.syntax += 1
@@ -853,9 +853,9 @@ class SnmpUSMSecurityModel(AbstractSecurityModel):
else:
# 3.2.7b.1
# noinspection PyUnboundLocalVariable
- if msgAuthoritativeEngineBoots > snmpEngineBoots or \
- msgAuthoritativeEngineBoots == snmpEngineBoots and \
- msgAuthoritativeEngineTime > latestReceivedEngineTime:
+ if (msgAuthoritativeEngineBoots > snmpEngineBoots or
+ msgAuthoritativeEngineBoots == snmpEngineBoots and
+ msgAuthoritativeEngineTime > latestReceivedEngineTime):
self.__timeline[msgAuthoritativeEngineId] = (
msgAuthoritativeEngineBoots,
msgAuthoritativeEngineTime,
@@ -874,10 +874,10 @@ class SnmpUSMSecurityModel(AbstractSecurityModel):
msgAuthoritativeEngineBoots, msgAuthoritativeEngineTime, msgAuthoritativeEngineId))
# 3.2.7b.2
- if snmpEngineBoots == 2147483647 or \
- msgAuthoritativeEngineBoots < snmpEngineBoots or \
- msgAuthoritativeEngineBoots == snmpEngineBoots and \
- abs(idleTime + int(snmpEngineTime) - int(msgAuthoritativeEngineTime)) > 150:
+ if (snmpEngineBoots == 2147483647 or
+ msgAuthoritativeEngineBoots < snmpEngineBoots or
+ msgAuthoritativeEngineBoots == snmpEngineBoots and
+ abs(idleTime + int(snmpEngineTime) - int(msgAuthoritativeEngineTime)) > 150):
raise error.StatusInformation(
errorIndication=errind.notInTimeWindow
)