summaryrefslogtreecommitdiff
path: root/examples/hlapi/trollius/manager/cmdgen/v1-get.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/hlapi/trollius/manager/cmdgen/v1-get.py')
-rw-r--r--examples/hlapi/trollius/manager/cmdgen/v1-get.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/examples/hlapi/trollius/manager/cmdgen/v1-get.py b/examples/hlapi/trollius/manager/cmdgen/v1-get.py
index c75be31d..d7406963 100644
--- a/examples/hlapi/trollius/manager/cmdgen/v1-get.py
+++ b/examples/hlapi/trollius/manager/cmdgen/v1-get.py
@@ -18,11 +18,14 @@ Functionally similar to:
import trollius
from pysnmp.hlapi.asyncio import *
+
@trollius.coroutine
def run():
snmpEngine = SnmpEngine()
- errorIndication, errorStatus, \
- errorIndex, varBinds = yield trollius.From(
+ (errorIndication,
+ errorStatus,
+ errorIndex,
+ varBinds) = yield trollius.From(
getCmd(snmpEngine,
CommunityData('public', mpModel=0),
UdpTransportTarget(('demo.snmplabs.com', 161)),
@@ -33,15 +36,13 @@ def run():
if errorIndication:
print(errorIndication)
elif errorStatus:
- print('%s at %s' % (
- errorStatus.prettyPrint(),
- errorIndex and varBinds[int(errorIndex)-1][0] or '?'
- )
- )
+ 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 ]))
+ print(' = '.join([x.prettyPrint() for x in varBind]))
snmpEngine.transportDispatcher.closeDispatcher()
+
trollius.get_event_loop().run_until_complete(run())