diff options
author | Ilya Etingof <etingof@gmail.com> | 2019-02-09 17:47:15 +0100 |
---|---|---|
committer | Ilya Etingof <etingof@gmail.com> | 2019-02-09 17:47:15 +0100 |
commit | 2b5603ecf98c1c47e94a405bd98054d1703af9e7 (patch) | |
tree | d0f544c895b238fbb5660dbf23b3d54c31bfa0b9 /pysnmp/entity | |
parent | 05b982f4b1cfa143d6fa607a6b9b24d3a77981a1 (diff) | |
download | pysnmp-git-2b5603ecf98c1c47e94a405bd98054d1703af9e7.tar.gz |
Drop Python < 2.6 except statement compatibility trick
Diffstat (limited to 'pysnmp/entity')
-rw-r--r-- | pysnmp/entity/engine.py | 4 | ||||
-rw-r--r-- | pysnmp/entity/rfc3413/cmdgen.py | 12 | ||||
-rw-r--r-- | pysnmp/entity/rfc3413/cmdrsp.py | 8 | ||||
-rw-r--r-- | pysnmp/entity/rfc3413/ntforg.py | 8 | ||||
-rw-r--r-- | pysnmp/entity/rfc3413/ntfrcv.py | 4 |
5 files changed, 18 insertions, 18 deletions
diff --git a/pysnmp/entity/engine.py b/pysnmp/entity/engine.py index a299267c..11abec6e 100644 --- a/pysnmp/entity/engine.py +++ b/pysnmp/entity/engine.py @@ -134,9 +134,9 @@ class SnmpEngine(object): os.write(fd, str2octs(snmpEngineBoots.syntax.prettyPrint())) os.close(fd) shutil.move(fn, f) - except Exception: + except Exception as exc: debug.logger & debug.flagApp and debug.logger( - 'SnmpEngine: could not stored SNMP Engine Boots: %s' % sys.exc_info()[1]) + 'SnmpEngine: could not stored SNMP Engine Boots: %s' % exc) else: debug.logger & debug.flagApp and debug.logger( 'SnmpEngine: stored SNMP Engine Boots: %s' % snmpEngineBoots.syntax.prettyPrint()) diff --git a/pysnmp/entity/rfc3413/cmdgen.py b/pysnmp/entity/rfc3413/cmdgen.py index 98cac48c..59503d52 100644 --- a/pysnmp/entity/rfc3413/cmdgen.py +++ b/pysnmp/entity/rfc3413/cmdgen.py @@ -92,8 +92,8 @@ class CommandGenerator(object): ) return - except StatusInformation: - statusInformation = sys.exc_info()[1] + except StatusInformation as exc: + statusInformation = exc debug.logger & debug.flagApp and debug.logger( 'processResponsePdu: origSendRequestHandle %s, _sendPdu() failed with %r' % ( sendPduHandle, statusInformation)) @@ -290,8 +290,8 @@ class NextCommandGenerator(NextCommandGeneratorSingleRun): (targetName, contextEngineId, contextName, reqPDU, cbFun, cbCtx)) - except StatusInformation: - statusInformation = sys.exc_info()[1] + except StatusInformation as exc: + statusInformation = exc debug.logger & debug.flagApp and debug.logger( 'sendVarBinds: sendPduHandle %s: sendPdu() failed with %r' % (sendRequestHandle, statusInformation)) cbFun(snmpEngine, sendRequestHandle, @@ -373,8 +373,8 @@ class BulkCommandGenerator(BulkCommandGeneratorSingleRun): (targetName, nonRepeaters, maxRepetitions, contextEngineId, contextName, reqPDU, cbFun, cbCtx)) - except StatusInformation: - statusInformation = sys.exc_info()[1] + except StatusInformation as exc: + statusInformation = exc debug.logger & debug.flagApp and debug.logger( 'processResponseVarBinds: sendPduHandle %s: _sendPdu() failed with %r' % ( sendRequestHandle, statusInformation)) diff --git a/pysnmp/entity/rfc3413/cmdrsp.py b/pysnmp/entity/rfc3413/cmdrsp.py index 44d73d50..0724518a 100644 --- a/pysnmp/entity/rfc3413/cmdrsp.py +++ b/pysnmp/entity/rfc3413/cmdrsp.py @@ -116,9 +116,9 @@ class CommandResponderBase(object): statusInformation ) - except error.StatusInformation: + except error.StatusInformation as exc: debug.logger & debug.flagApp and debug.logger( - 'sendPdu: stateReference %s, statusInformation %s' % (stateReference, sys.exc_info()[1])) + 'sendPdu: stateReference %s, statusInformation %s' % (stateReference, exc)) snmpSilentDrops, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', 'snmpSilentDrops') snmpSilentDrops.syntax += 1 @@ -200,8 +200,8 @@ class CommandResponderBase(object): ) # Map ACM errors onto SMI ones - except error.StatusInformation: - statusInformation = sys.exc_info()[1] + except error.StatusInformation as exc: + statusInformation = exc debug.logger & debug.flagApp and debug.logger( '__verifyAccess: name %s, statusInformation %s' % (name, statusInformation)) errorIndication = statusInformation['errorIndication'] diff --git a/pysnmp/entity/rfc3413/ntforg.py b/pysnmp/entity/rfc3413/ntforg.py index 19442b3a..263dbb79 100644 --- a/pysnmp/entity/rfc3413/ntforg.py +++ b/pysnmp/entity/rfc3413/ntforg.py @@ -87,8 +87,8 @@ class NotificationOriginator(object): reqPDU, True, timeoutInTicks, self.processResponsePdu, (sendRequestHandle, cbFun, cbCtx) ) - except error.StatusInformation: - statusInformation = sys.exc_info()[1] + except error.StatusInformation as exc: + statusInformation = exc debug.logger & debug.flagApp and debug.logger( 'processResponsePdu: sendRequestHandle %s: sendPdu() failed with %r ' % ( sendRequestHandle, statusInformation)) @@ -303,8 +303,8 @@ class NotificationOriginator(object): (notificationHandle, cbFun, cbCtx) ) - except error.StatusInformation: - statusInformation = sys.exc_info()[1] + except error.StatusInformation as exc: + statusInformation = exc debug.logger & debug.flagApp and debug.logger( 'sendVarBinds: sendRequestHandle %s: sendPdu() failed with %r' % ( sendRequestHandle, statusInformation)) diff --git a/pysnmp/entity/rfc3413/ntfrcv.py b/pysnmp/entity/rfc3413/ntfrcv.py index fbec47ca..9e3fcc24 100644 --- a/pysnmp/entity/rfc3413/ntfrcv.py +++ b/pysnmp/entity/rfc3413/ntfrcv.py @@ -84,9 +84,9 @@ class NotificationReceiver(object): contextName, pduVersion, rspPDU, maxSizeResponseScopedPDU, stateReference, statusInformation) - except error.StatusInformation: + except error.StatusInformation as exc: debug.logger & debug.flagApp and debug.logger( - 'processPdu: stateReference %s, statusInformation %s' % (stateReference, sys.exc_info()[1])) + 'processPdu: stateReference %s, statusInformation %s' % (stateReference, exc)) snmpSilentDrops, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', 'snmpSilentDrops') snmpSilentDrops.syntax += 1 |