From e4c4e376316835e9eff0ac4df15ec29db7a7808b Mon Sep 17 00:00:00 2001 From: Ilya Etingof Date: Wed, 30 Mar 2016 23:56:16 +0200 Subject: pep8 fixes --- .../manager/cmdgen/multiple-concurrent-queries.py | 7 ++--- .../asyncore/manager/cmdgen/pull-whole-mib.py | 3 +- .../manager/cmdgen/query-multiple-snmp-engines.py | 3 +- examples/hlapi/asyncore/manager/cmdgen/v2c-get.py | 3 +- .../hlapi/trollius/agent/ntforg/default-v1-trap.py | 13 +++++--- .../trollius/manager/cmdgen/getbulk-to-eom.py | 35 +++++++++++----------- examples/hlapi/trollius/manager/cmdgen/v1-get.py | 17 ++++++----- 7 files changed, 44 insertions(+), 37 deletions(-) (limited to 'examples') diff --git a/examples/hlapi/asyncore/manager/cmdgen/multiple-concurrent-queries.py b/examples/hlapi/asyncore/manager/cmdgen/multiple-concurrent-queries.py index 2d8bebaa..2b4b0eb3 100644 --- a/examples/hlapi/asyncore/manager/cmdgen/multiple-concurrent-queries.py +++ b/examples/hlapi/asyncore/manager/cmdgen/multiple-concurrent-queries.py @@ -62,11 +62,8 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication, print(errorIndication) return True 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 '?')) return True else: for varBind in varBinds: diff --git a/examples/hlapi/asyncore/manager/cmdgen/pull-whole-mib.py b/examples/hlapi/asyncore/manager/cmdgen/pull-whole-mib.py index c29c3559..8d9ff19e 100644 --- a/examples/hlapi/asyncore/manager/cmdgen/pull-whole-mib.py +++ b/examples/hlapi/asyncore/manager/cmdgen/pull-whole-mib.py @@ -25,7 +25,8 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication, print(errorIndication) return elif errorStatus: - print('%s at %s' % (errorStatus.prettyPrint(), errorIndex and varBindTable[-1][int(errorIndex) - 1][0] or '?')) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBindTable[-1][int(errorIndex) - 1][0] or '?')) return else: for varBindRow in varBindTable: diff --git a/examples/hlapi/asyncore/manager/cmdgen/query-multiple-snmp-engines.py b/examples/hlapi/asyncore/manager/cmdgen/query-multiple-snmp-engines.py index ce8613a6..4a732041 100644 --- a/examples/hlapi/asyncore/manager/cmdgen/query-multiple-snmp-engines.py +++ b/examples/hlapi/asyncore/manager/cmdgen/query-multiple-snmp-engines.py @@ -64,7 +64,8 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication, print(errorIndication) return True 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 '?')) return True else: for varBind in varBinds: diff --git a/examples/hlapi/asyncore/manager/cmdgen/v2c-get.py b/examples/hlapi/asyncore/manager/cmdgen/v2c-get.py index 29748a61..d752b540 100644 --- a/examples/hlapi/asyncore/manager/cmdgen/v2c-get.py +++ b/examples/hlapi/asyncore/manager/cmdgen/v2c-get.py @@ -24,7 +24,8 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication, print(errorIndication) return elif errorStatus: - print('%s at %s' % (errorStatus.prettyPrint(), errorIndex and varBindTable[-1][int(errorIndex) - 1][0] or '?')) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBindTable[-1][int(errorIndex) - 1][0] or '?')) return else: for varBind in varBinds: diff --git a/examples/hlapi/trollius/agent/ntforg/default-v1-trap.py b/examples/hlapi/trollius/agent/ntforg/default-v1-trap.py index 6394dbd3..514cff2f 100644 --- a/examples/hlapi/trollius/agent/ntforg/default-v1-trap.py +++ b/examples/hlapi/trollius/agent/ntforg/default-v1-trap.py @@ -24,14 +24,17 @@ 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( sendNotification( snmpEngine, - CommunityData('public'), # mpModel=0), + CommunityData('public'), # mpModel=0), UdpTransportTarget(('demo.snmplabs.com', 162)), ContextData(), 'inform', @@ -47,11 +50,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])) snmpEngine.transportDispatcher.closeDispatcher() + trollius.get_event_loop().run_until_complete(run()) diff --git a/examples/hlapi/trollius/manager/cmdgen/getbulk-to-eom.py b/examples/hlapi/trollius/manager/cmdgen/getbulk-to-eom.py index 6d4cf714..b380b283 100644 --- a/examples/hlapi/trollius/manager/cmdgen/getbulk-to-eom.py +++ b/examples/hlapi/trollius/manager/cmdgen/getbulk-to-eom.py @@ -13,40 +13,39 @@ Send a series of SNMP GETBULK requests using the following options: Functionally similar to: -| $ snmpbulkwalk -v3 -lnoAuthNoPriv -u usr-none-none -Cn0 -Cr50 \ -| demo.snmplabs.com SNMPv2-MIB::system +| $ snmpbulkwalk -v3 -lnoAuthNoPriv -u usr-none-none -Cn0 -Cr50 demo.snmplabs.com SNMPv2-MIB::system """# import trollius from pysnmp.hlapi.asyncio import * + @trollius.coroutine def run(varBinds): snmpEngine = SnmpEngine() while True: - errorIndication, errorStatus, errorIndex, \ - varBindTable = yield trollius.From( - bulkCmd(snmpEngine, - UsmUserData('usr-none-none'), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ContextData(), - 0, 50, - *varBinds) - ) + (errorIndication, + errorStatus, + errorIndex, + varBindTable) = yield trollius.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 '?' - ) - ) + print('%s at %s' % (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): @@ -54,7 +53,9 @@ def run(varBinds): snmpEngine.transportDispatcher.closeDispatcher() + loop = trollius.get_event_loop() + loop.run_until_complete( run([ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr'))]) ) 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()) -- cgit v1.2.1