summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelie <elie>2010-12-13 00:06:48 +0000
committerelie <elie>2010-12-13 00:06:48 +0000
commit07b8e7a99c340673fcf7962c2258933d24806017 (patch)
tree41c6b6cbb545ee0abadd7caa1ca2494fd584962f
parent168a94a018bce47a701fa8c5380269b1111ec9ca (diff)
downloadpysnmp-07b8e7a99c340673fcf7962c2258933d24806017.tar.gz
fix to EOM condition detection
-rw-r--r--examples/v3arch/twisted/manager/bulkgen.py31
1 files changed, 17 insertions, 14 deletions
diff --git a/examples/v3arch/twisted/manager/bulkgen.py b/examples/v3arch/twisted/manager/bulkgen.py
index 1ca8cc6..4a6f07f 100644
--- a/examples/v3arch/twisted/manager/bulkgen.py
+++ b/examples/v3arch/twisted/manager/bulkgen.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 = bulkCmdGen.sendReq(
- snmpEngine, 'myRouter', 0, 25, varBindTable[-1]
- )
- df.addCallback(receiveResponse, bulkCmdGen, 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 = bulkCmdGen.sendReq(
+ snmpEngine, 'myRouter', 0, 25, varBindTable[-1]
+ )
+ df.addCallback(receiveResponse, bulkCmdGen, snmpEngine)
bulkCmdGen = cmdgen.BulkCommandGenerator()