summaryrefslogtreecommitdiff
path: root/examples/hlapi/v3arch/asyncore/sync/manager/cmdgen/get-table-object-by-index.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/hlapi/v3arch/asyncore/sync/manager/cmdgen/get-table-object-by-index.py')
-rw-r--r--examples/hlapi/v3arch/asyncore/sync/manager/cmdgen/get-table-object-by-index.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/examples/hlapi/v3arch/asyncore/sync/manager/cmdgen/get-table-object-by-index.py b/examples/hlapi/v3arch/asyncore/sync/manager/cmdgen/get-table-object-by-index.py
index ed5d8351..253b9224 100644
--- a/examples/hlapi/v3arch/asyncore/sync/manager/cmdgen/get-table-object-by-index.py
+++ b/examples/hlapi/v3arch/asyncore/sync/manager/cmdgen/get-table-object-by-index.py
@@ -17,20 +17,24 @@ Functionally similar to:
"""#
from pysnmp.hlapi import *
-errorIndication, errorStatus, errorIndex, varBinds = next(
- getCmd(SnmpEngine(),
- UsmUserData('usr-none-none'),
- UdpTransportTarget(('demo.snmplabs.com', 161)),
- ContextData(),
- ObjectType(ObjectIdentity('IF-MIB', 'ifInOctets', 1)),
- ObjectType(ObjectIdentity('IF-MIB', 'ifOutOctets', 1)))
+iterator = getCmd(
+ SnmpEngine(),
+ UsmUserData('usr-none-none'),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ContextData(),
+ ObjectType(ObjectIdentity('IF-MIB', 'ifInOctets', 1)),
+ ObjectType(ObjectIdentity('IF-MIB', 'ifOutOctets', 1))
)
+errorIndication, errorStatus, errorIndex, varBinds = next(iterator)
+
if errorIndication:
print(errorIndication)
+
elif errorStatus:
print('%s at %s' % (errorStatus.prettyPrint(),
errorIndex and varBinds[int(errorIndex) - 1][0] or '?'))
+
else:
for varBind in varBinds:
print(' = '.join([x.prettyPrint() for x in varBind]))