summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorelie <elie>2010-12-12 22:36:45 +0000
committerelie <elie>2010-12-12 22:36:45 +0000
commita08d98dab6abb4b46e3f57d25464b2e8d9af6e36 (patch)
tree03e3526fe023901130c565e1462c3ed47a5f0506 /examples
parent53de73fa70ba2434d58bab64788b732f276b9db4 (diff)
downloadpysnmp-a08d98dab6abb4b46e3f57d25464b2e8d9af6e36.tar.gz
fix to EOM condition detection
Diffstat (limited to 'examples')
-rw-r--r--examples/v3arch/twisted/manager/nextgen.py31
1 files changed, 17 insertions, 14 deletions
diff --git a/examples/v3arch/twisted/manager/nextgen.py b/examples/v3arch/twisted/manager/nextgen.py
index 5889bea..e072871 100644
--- a/examples/v3arch/twisted/manager/nextgen.py
+++ b/examples/v3arch/twisted/manager/nextgen.py
@@ -4,6 +4,7 @@ from pysnmp.entity import engine, config
from pysnmp.carrier.twisted import dispatch
from pysnmp.carrier.twisted.dgram import udp
from pysnmp.entity.rfc3413.twisted import cmdgen
+from pyasn1.type import univ
snmpEngine = engine.SnmpEngine()
@@ -46,25 +47,27 @@ def receiveResponse(
print 'Error: ', errorIndication
reactor.stop()
return
- if errorStatus:
- print 'Error: ', errorStatus.prettyPrint(), errorIndex
+ if errorStatus and errorStatus != 2:
+ print '%s at %s\n' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBindTable[-1][int(errorIndex)-1] or '?'
+ )
reactor.stop()
return
for varBindRow in varBindTable:
for oid, val in varBindRow:
- if val is None:
- print oid.prettyPrint()
- else:
- print '%s = %s' % (oid.prettyPrint(), val.prettyPrint())
- for oid, val in varBindTable[-1]:
- if val is not None:
- df = nextCmdGen.sendReq(
- snmpEngine, 'myRouter', varBindTable[-1]
- )
- df.addCallback(receiveResponse, nextCmdGen, snmpEngine)
- return
+ print '%s = %s' % (oid.prettyPrint(), val.prettyPrint())
+
+ for o, v in varBindTable[-1]:
+ if not isinstance(v, univ.Null):
+ break
else:
- reactor.stop()
+ reactor.stop() # no more objects available
+
+ df = nextCmdGen.sendReq(
+ snmpEngine, 'myRouter', varBindTable[-1]
+ )
+ df.addCallback(receiveResponse, nextCmdGen, snmpEngine)
nextCmdGen = cmdgen.NextCommandGenerator()