summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorIlya Etingof <etingof@gmail.com>2016-03-30 23:56:16 +0200
committerIlya Etingof <etingof@gmail.com>2016-03-30 23:56:16 +0200
commite4c4e376316835e9eff0ac4df15ec29db7a7808b (patch)
tree201df381a315fad81cdb280e5feeb63c2cd3b76d /examples
parent929eb1b5339e13b77d1f75fca1efc79adb316223 (diff)
downloadpysnmp-git-e4c4e376316835e9eff0ac4df15ec29db7a7808b.tar.gz
pep8 fixes
Diffstat (limited to 'examples')
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/multiple-concurrent-queries.py7
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/pull-whole-mib.py3
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/query-multiple-snmp-engines.py3
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/v2c-get.py3
-rw-r--r--examples/hlapi/trollius/agent/ntforg/default-v1-trap.py13
-rw-r--r--examples/hlapi/trollius/manager/cmdgen/getbulk-to-eom.py35
-rw-r--r--examples/hlapi/trollius/manager/cmdgen/v1-get.py17
7 files changed, 44 insertions, 37 deletions
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())