diff options
Diffstat (limited to 'examples/hlapi/asyncio/manager/cmdgen/getbulk-to-eom.py')
-rw-r--r-- | examples/hlapi/asyncio/manager/cmdgen/getbulk-to-eom.py | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/examples/hlapi/asyncio/manager/cmdgen/getbulk-to-eom.py b/examples/hlapi/asyncio/manager/cmdgen/getbulk-to-eom.py index c5556838..b45057e3 100644 --- a/examples/hlapi/asyncio/manager/cmdgen/getbulk-to-eom.py +++ b/examples/hlapi/asyncio/manager/cmdgen/getbulk-to-eom.py @@ -20,32 +20,33 @@ Functionally similar to: import asyncio from pysnmp.hlapi.asyncio import * + @asyncio.coroutine def run(varBinds): snmpEngine = SnmpEngine() while True: errorIndication, errorStatus, errorIndex, \ - varBindTable = yield from bulkCmd( - snmpEngine, - UsmUserData('usr-none-none'), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ContextData(), - 0, 50, - *varBinds) + varBindTable = yield from bulkCmd( + snmpEngine, + UsmUserData('usr-none-none'), + UdpTransportTarget(('demo.snmplabs.com', 161)), + ContextData(), + 0, 50, + *varBinds) if errorIndication: print(errorIndication) break elif errorStatus: print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) + errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?' ) + ) else: for varBindRow in varBindTable: for varBind in varBindRow: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) varBinds = varBindTable[-1] if isEndOfMib(varBinds): @@ -53,6 +54,7 @@ def run(varBinds): snmpEngine.transportDispatcher.closeDispatcher() + loop = asyncio.get_event_loop() loop.run_until_complete( run([ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr'))]) |