summaryrefslogtreecommitdiff
path: root/pysnmp/entity
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/entity
parent72759c534ce3546c1a8f50321d29cf1d587ce7df (diff)
downloadpysnmp-git-c196de621f8e88faa7b8b9fe1ec43cfdd9687576.tar.gz
minor pep8 improvements
Diffstat (limited to 'pysnmp/entity')
-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
6 files changed, 71 insertions, 76 deletions
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: