summaryrefslogtreecommitdiff
path: root/examples/hlapi/v3arch/asyncore/sync/manager/cmdgen/usm-none-none.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/hlapi/v3arch/asyncore/sync/manager/cmdgen/usm-none-none.py')
-rw-r--r--examples/hlapi/v3arch/asyncore/sync/manager/cmdgen/usm-none-none.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/examples/hlapi/v3arch/asyncore/sync/manager/cmdgen/usm-none-none.py b/examples/hlapi/v3arch/asyncore/sync/manager/cmdgen/usm-none-none.py
index 940d8817..8a558920 100644
--- a/examples/hlapi/v3arch/asyncore/sync/manager/cmdgen/usm-none-none.py
+++ b/examples/hlapi/v3arch/asyncore/sync/manager/cmdgen/usm-none-none.py
@@ -16,18 +16,22 @@ 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)))
+iterator = getCmd(
+ SnmpEngine(),
+ UsmUserData('usr-none-none'),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ContextData(),
+ ObjectType(ObjectIdentity('IF-MIB', 'ifInOctets', 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]))