summaryrefslogtreecommitdiff
path: root/examples/hlapi/asyncore/sync/manager/cmdgen/get-table-object-by-index.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/hlapi/asyncore/sync/manager/cmdgen/get-table-object-by-index.py')
-rw-r--r--examples/hlapi/asyncore/sync/manager/cmdgen/get-table-object-by-index.py44
1 files changed, 22 insertions, 22 deletions
diff --git a/examples/hlapi/asyncore/sync/manager/cmdgen/get-table-object-by-index.py b/examples/hlapi/asyncore/sync/manager/cmdgen/get-table-object-by-index.py
index c6419934..e83e0d2a 100644
--- a/examples/hlapi/asyncore/sync/manager/cmdgen/get-table-object-by-index.py
+++ b/examples/hlapi/asyncore/sync/manager/cmdgen/get-table-object-by-index.py
@@ -9,27 +9,27 @@
# * for IF-MIB::ifInOctets.1 MIB object
# * perform response OIDs and values resolution at MIB
#
-from pysnmp.entity.rfc3413.oneliner import cmdgen
+from pysnmp.entity.rfc3413.oneliner.cmdgen import *
-cmdGen = cmdgen.CommandGenerator()
-
-errorIndication, errorStatus, errorIndex, varBinds = cmdGen.getCmd(
- cmdgen.UsmUserData('usr-none-none'),
- cmdgen.UdpTransportTarget(('demo.snmplabs.com', 161)),
- cmdgen.ObjectIdentity('IF-MIB', 'ifInOctets', 1),
- lookupNames=True, lookupValues=True
-)
-
-# Check for errors and print out results
-if errorIndication:
- print(errorIndication)
-else:
- if errorStatus:
- print('%s at %s' % (
- errorStatus.prettyPrint(),
- errorIndex and varBinds[int(errorIndex)-1][0] or '?'
- )
- )
+for errorIndication, \
+ errorStatus, errorIndex, \
+ varBinds in getCmd(SnmpEngine(),
+ UsmUserData('usr-none-none'),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ContextData(),
+ ObjectType(ObjectIdentity('IF-MIB', 'ifInOctets', 1)),
+ lookupNames=True, lookupValues=True):
+ # Check for errors and print out results
+ if errorIndication:
+ print(errorIndication)
else:
- for name, val in varBinds:
- print('%s = %s' % (name.prettyPrint(), val.prettyPrint()))
+ if 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 ]))
+ break