summaryrefslogtreecommitdiff
path: root/examples/v3arch/asyncore/manager/cmdgen
diff options
context:
space:
mode:
Diffstat (limited to 'examples/v3arch/asyncore/manager/cmdgen')
-rw-r--r--examples/v3arch/asyncore/manager/cmdgen/custom-contextengineid-and-contextname.py11
-rw-r--r--examples/v3arch/asyncore/manager/cmdgen/custom-timeout-and-retries.py13
-rw-r--r--examples/v3arch/asyncore/manager/cmdgen/fetch-variables-over-ipv6.py15
-rw-r--r--examples/v3arch/asyncore/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py17
-rw-r--r--examples/v3arch/asyncore/manager/cmdgen/getbulk-multiple-oids-to-eom.py17
-rw-r--r--examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-and-resolve-with-mib.py20
-rw-r--r--examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-to-eom.py15
-rw-r--r--examples/v3arch/asyncore/manager/cmdgen/observe-request-processing.py15
-rw-r--r--examples/v3arch/asyncore/manager/cmdgen/pull-subtree.py15
-rw-r--r--examples/v3arch/asyncore/manager/cmdgen/send-packets-from-specific-interface.py15
-rw-r--r--examples/v3arch/asyncore/manager/cmdgen/set-multiple-scalar-values.py13
-rw-r--r--examples/v3arch/asyncore/manager/cmdgen/spoof-source-address.py11
-rw-r--r--examples/v3arch/asyncore/manager/cmdgen/usm-sha-aes128.py11
-rw-r--r--examples/v3arch/asyncore/manager/cmdgen/usm-sha-none.py11
-rw-r--r--examples/v3arch/asyncore/manager/cmdgen/v1-get.py11
-rw-r--r--examples/v3arch/asyncore/manager/cmdgen/v2c-set.py11
16 files changed, 104 insertions, 117 deletions
diff --git a/examples/v3arch/asyncore/manager/cmdgen/custom-contextengineid-and-contextname.py b/examples/v3arch/asyncore/manager/cmdgen/custom-contextengineid-and-contextname.py
index eb1900c2..1f3fdaf2 100644
--- a/examples/v3arch/asyncore/manager/cmdgen/custom-contextengineid-and-contextname.py
+++ b/examples/v3arch/asyncore/manager/cmdgen/custom-contextengineid-and-contextname.py
@@ -53,6 +53,7 @@ config.addTargetAddr(
'my-creds'
)
+
# Error/response receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
@@ -60,15 +61,13 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication,
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 oid, val in varBinds:
print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
+
# Prepare and send a request message, pass custom ContextEngineId & ContextName
cmdgen.GetCommandGenerator().sendVarBinds(
snmpEngine,
@@ -77,7 +76,7 @@ cmdgen.GetCommandGenerator().sendVarBinds(
rfc1902.OctetString(hexValue='80004fb805636c6f75644dab22cc'),
# contextName
rfc1902.OctetString('da761cfc8c94d3aceef4f60f049105ba'),
- [ ((1,3,6,1,2,1,1,1,0), None) ],
+ [((1, 3, 6, 1, 2, 1, 1, 1, 0), None)],
cbFun
)
diff --git a/examples/v3arch/asyncore/manager/cmdgen/custom-timeout-and-retries.py b/examples/v3arch/asyncore/manager/cmdgen/custom-timeout-and-retries.py
index 1e49ffef..c30ff4c1 100644
--- a/examples/v3arch/asyncore/manager/cmdgen/custom-timeout-and-retries.py
+++ b/examples/v3arch/asyncore/manager/cmdgen/custom-timeout-and-retries.py
@@ -51,6 +51,7 @@ config.addTargetAddr(
retryCount=5
)
+
# Error/response receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
@@ -58,21 +59,19 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication,
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 oid, val in varBinds:
print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
+
# Prepare and send a request message
cmdgen.GetCommandGenerator().sendVarBinds(
snmpEngine,
'my-router',
- None, '', # contextEngineId, contextName
- [ ((1,3,6,1,2,1,1,1,0), None) ],
+ None, '', # contextEngineId, contextName
+ [((1, 3, 6, 1, 2, 1, 1, 1, 0), None)],
cbFun
)
diff --git a/examples/v3arch/asyncore/manager/cmdgen/fetch-variables-over-ipv6.py b/examples/v3arch/asyncore/manager/cmdgen/fetch-variables-over-ipv6.py
index 916537da..45460c92 100644
--- a/examples/v3arch/asyncore/manager/cmdgen/fetch-variables-over-ipv6.py
+++ b/examples/v3arch/asyncore/manager/cmdgen/fetch-variables-over-ipv6.py
@@ -50,6 +50,7 @@ config.addTargetAddr(
'my-creds'
)
+
# Error/response receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
@@ -58,24 +59,22 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication,
print(errorIndication)
return
if 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 # stop on error
for varBindRow in varBindTable:
for oid, val in varBindRow:
print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
- return True # signal dispatcher to continue
+ return True # signal dispatcher to continue
+
# Prepare initial request to be sent
cmdgen.NextCommandGenerator().sendVarBinds(
snmpEngine,
'my-router',
None, '', # contextEngineId, contextName
- [ ((1,3,6,1,2,1,1), None),
- ((1,3,6,1,4,1,1), None) ],
+ [((1, 3, 6, 1, 2, 1, 1), None),
+ ((1, 3, 6, 1, 4, 1, 1), None)],
cbFun
)
diff --git a/examples/v3arch/asyncore/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py b/examples/v3arch/asyncore/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py
index 516951f8..8c4bf3dd 100644
--- a/examples/v3arch/asyncore/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py
+++ b/examples/v3arch/asyncore/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py
@@ -52,6 +52,7 @@ config.addTargetAddr(
'my-creds'
)
+
# Error/response receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, sendRequesthandle, errorIndication,
@@ -60,25 +61,23 @@ def cbFun(snmpEngine, sendRequesthandle, errorIndication,
print(errorIndication)
return # stop on error
if 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 # stop on error
for varBindRow in varBindTable:
for oid, val in varBindRow:
print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
- return True # signal dispatcher to continue walking
+ return True # signal dispatcher to continue walking
+
# Prepare initial request to be sent
cmdgen.BulkCommandGenerator().sendVarBinds(
snmpEngine,
'my-router',
None, '', # contextEngineId, contextName
- 0, 25, # non-repeaters, max-repetitions
- ( ((1,3,6,1,2,1,1), None),
- ((1,3,6,1,4,1,1), None) ),
+ 0, 25, # non-repeaters, max-repetitions
+ (((1, 3, 6, 1, 2, 1, 1), None),
+ ((1, 3, 6, 1, 4, 1, 1), None)),
cbFun
)
diff --git a/examples/v3arch/asyncore/manager/cmdgen/getbulk-multiple-oids-to-eom.py b/examples/v3arch/asyncore/manager/cmdgen/getbulk-multiple-oids-to-eom.py
index 2cd37cda..29c480c1 100644
--- a/examples/v3arch/asyncore/manager/cmdgen/getbulk-multiple-oids-to-eom.py
+++ b/examples/v3arch/asyncore/manager/cmdgen/getbulk-multiple-oids-to-eom.py
@@ -49,6 +49,7 @@ config.addTargetAddr(
'my-creds'
)
+
# Error/response receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, sendRequesthandle, errorIndication,
@@ -57,25 +58,23 @@ def cbFun(snmpEngine, sendRequesthandle, errorIndication,
print(errorIndication)
return # stop on error
if 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 # stop on error
for varBindRow in varBindTable:
for oid, val in varBindRow:
print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
- return True # signal dispatcher to continue walking
+ return True # signal dispatcher to continue walking
+
# Prepare initial request to be sent
cmdgen.BulkCommandGenerator().sendVarBinds(
snmpEngine,
'my-router',
None, '', # contextEngineId, contextName
- 0, 25, # non-repeaters, max-repetitions
- [ ((1,3,6,1,2,1,1), None),
- ((1,3,6,1,4,1,1), None) ],
+ 0, 25, # non-repeaters, max-repetitions
+ [((1, 3, 6, 1, 2, 1, 1), None),
+ ((1, 3, 6, 1, 4, 1, 1), None)],
cbFun
)
diff --git a/examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-and-resolve-with-mib.py b/examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-and-resolve-with-mib.py
index f4667bef..9caf6a89 100644
--- a/examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-and-resolve-with-mib.py
+++ b/examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-and-resolve-with-mib.py
@@ -27,7 +27,7 @@ snmpEngine = engine.SnmpEngine()
# This call will fail if PySMI is not present on the system
compiler.addMibCompiler(snmpEngine.getMibBuilder())
# ... alternatively, this call will not complain on missing PySMI
-#compiler.addMibCompiler(snmpEngine.getMibBuilder(), ifAvailable=True)
+# compiler.addMibCompiler(snmpEngine.getMibBuilder(), ifAvailable=True)
# Used for MIB objects resolution
mibViewController = view.MibViewController(snmpEngine.getMibBuilder())
@@ -60,6 +60,7 @@ config.addTargetAddr(
'my-creds'
)
+
# Error/response receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
@@ -70,24 +71,23 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication,
# SNMPv1 response may contain noSuchName error *and* SNMPv2c exception,
# so we ignore noSuchName error here
if errorStatus and errorStatus != 2:
- 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 # stop on error
for varBindRow in varBindTable:
for varBind in varBindRow:
- print(rfc1902.ObjectType(rfc1902.ObjectIdentity(varBind[0]), varBind[1]).resolveWithMib(mibViewController).prettyPrint())
- return 1 # signal dispatcher to continue
+ print(rfc1902.ObjectType(rfc1902.ObjectIdentity(varBind[0]),
+ varBind[1]).resolveWithMib(mibViewController).prettyPrint())
+ return 1 # signal dispatcher to continue
+
# Prepare initial request to be sent
cmdgen.NextCommandGenerator().sendVarBinds(
snmpEngine,
'my-router',
None, '', # contextEngineId, contextName
- [ rfc1902.ObjectType(rfc1902.ObjectIdentity('iso.org.dod')).resolveWithMib(mibViewController),
- rfc1902.ObjectType(rfc1902.ObjectIdentity('IF-MIB', 'ifMIB')).resolveWithMib(mibViewController) ],
+ [rfc1902.ObjectType(rfc1902.ObjectIdentity('iso.org.dod')).resolveWithMib(mibViewController),
+ rfc1902.ObjectType(rfc1902.ObjectIdentity('IF-MIB', 'ifMIB')).resolveWithMib(mibViewController)],
cbFun
)
diff --git a/examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-to-eom.py b/examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-to-eom.py
index f2bcc43e..d90c35bb 100644
--- a/examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-to-eom.py
+++ b/examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-to-eom.py
@@ -49,6 +49,7 @@ config.addTargetAddr(
'my-creds'
)
+
# Error/response receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
@@ -59,24 +60,22 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication,
# SNMPv1 response may contain noSuchName error *and* SNMPv2c exception,
# so we ignore noSuchName error here
if errorStatus and errorStatus != 2:
- 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 # stop on error
for varBindRow in varBindTable:
for oid, val in varBindRow:
print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
- return 1 # signal dispatcher to continue
+ return 1 # signal dispatcher to continue
+
# Prepare initial request to be sent
cmdgen.NextCommandGenerator().sendVarBinds(
snmpEngine,
'my-router',
None, '', # contextEngineId, contextName
- [ ((1,3,6,1,2,1,1), None),
- ((1,3,6,1,4,1,1), None) ],
+ [((1, 3, 6, 1, 2, 1, 1), None),
+ ((1, 3, 6, 1, 4, 1, 1), None)],
cbFun
)
diff --git a/examples/v3arch/asyncore/manager/cmdgen/observe-request-processing.py b/examples/v3arch/asyncore/manager/cmdgen/observe-request-processing.py
index 86187923..6034624c 100644
--- a/examples/v3arch/asyncore/manager/cmdgen/observe-request-processing.py
+++ b/examples/v3arch/asyncore/manager/cmdgen/observe-request-processing.py
@@ -25,6 +25,7 @@ from pysnmp.entity.rfc3413 import cmdgen
# Create SNMP engine instance
snmpEngine = engine.SnmpEngine()
+
# Execution point observer setup
# Register a callback to be invoked at specified execution point of
@@ -41,8 +42,9 @@ def requestObserver(snmpEngine, execpoint, variables, cbCtx):
print('* contextName: %s' % variables['contextName'].prettyPrint())
print('* PDU: %s' % variables['pdu'].prettyPrint())
+
snmpEngine.observer.registerObserver(
- requestObserver,
+ requestObserver,
'rfc3412.sendPdu',
'rfc3412.receiveMessage:response'
)
@@ -76,6 +78,7 @@ config.addTargetAddr(
'my-creds'
)
+
# Error/response receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
@@ -83,21 +86,19 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication,
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 oid, val in varBinds:
print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
+
# Prepare and send a request message
cmdgen.GetCommandGenerator().sendVarBinds(
snmpEngine,
'my-router',
None, '', # contextEngineId, contextName
- [ ((1,3,6,1,2,1,1,1,0), None) ],
+ [((1, 3, 6, 1, 2, 1, 1, 1, 0), None)],
cbFun
)
diff --git a/examples/v3arch/asyncore/manager/cmdgen/pull-subtree.py b/examples/v3arch/asyncore/manager/cmdgen/pull-subtree.py
index 36e461fb..cbaa1d0b 100644
--- a/examples/v3arch/asyncore/manager/cmdgen/pull-subtree.py
+++ b/examples/v3arch/asyncore/manager/cmdgen/pull-subtree.py
@@ -52,6 +52,7 @@ config.addTargetAddr(
'my-creds'
)
+
# Error/response receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
@@ -60,26 +61,24 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication,
print(errorIndication)
return
if 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 # stop on error
for varBindRow in varBindTable:
for oid, val in varBindRow:
if initialOID.isPrefixOf(oid):
print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
else:
- return False # signal dispatcher to stop
- return True # signal dispatcher to continue
+ return False # signal dispatcher to stop
+ return True # signal dispatcher to continue
+
# Prepare initial request to be sent
cmdgen.NextCommandGenerator().sendVarBinds(
snmpEngine,
'my-router',
None, '', # contextEngineId, contextName
- [ (initialOID, None) ],
+ [(initialOID, None)],
cbFun
)
diff --git a/examples/v3arch/asyncore/manager/cmdgen/send-packets-from-specific-interface.py b/examples/v3arch/asyncore/manager/cmdgen/send-packets-from-specific-interface.py
index 27acf769..2d6805fa 100644
--- a/examples/v3arch/asyncore/manager/cmdgen/send-packets-from-specific-interface.py
+++ b/examples/v3arch/asyncore/manager/cmdgen/send-packets-from-specific-interface.py
@@ -50,6 +50,7 @@ config.addTargetAddr(
'my-creds'
)
+
# Error/response receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
@@ -58,24 +59,22 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication,
print(errorIndication)
return
if 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 # stop on error
for varBindRow in varBindTable:
for oid, val in varBindRow:
print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
- return 1 # signal dispatcher to continue
+ return 1 # signal dispatcher to continue
+
# Prepare initial request to be sent
cmdgen.NextCommandGenerator().sendVarBinds(
snmpEngine,
'my-router',
None, '', # contextEngineId, contextName
- [ ((1,3,6,1,2,1,1), None),
- ((1,3,6,1,2,1,11), None) ],
+ [((1, 3, 6, 1, 2, 1, 1), None),
+ ((1, 3, 6, 1, 2, 1, 11), None)],
cbFun
)
diff --git a/examples/v3arch/asyncore/manager/cmdgen/set-multiple-scalar-values.py b/examples/v3arch/asyncore/manager/cmdgen/set-multiple-scalar-values.py
index 28095a76..25a33fd0 100644
--- a/examples/v3arch/asyncore/manager/cmdgen/set-multiple-scalar-values.py
+++ b/examples/v3arch/asyncore/manager/cmdgen/set-multiple-scalar-values.py
@@ -49,6 +49,7 @@ config.addTargetAddr(
'my-creds'
)
+
# Error/response receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
@@ -58,22 +59,20 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication,
# SNMPv1 response may contain noSuchName error *and* SNMPv2c exception,
# so we ignore noSuchName error here
elif errorStatus and errorStatus != 2:
- 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 oid, val in varBinds:
print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
+
# Prepare and send a request message
cmdgen.SetCommandGenerator().sendVarBinds(
snmpEngine,
'my-router',
None, '', # contextEngineId, contextName
- [ ((1,3,6,1,2,1,1,9,1,3,1), rfc1902.OctetString('my value')),
- ((1,3,6,1,2,1,1,9,1,4,1), rfc1902.TimeTicks(123)) ],
+ [((1, 3, 6, 1, 2, 1, 1, 9, 1, 3, 1), rfc1902.OctetString('my value')),
+ ((1, 3, 6, 1, 2, 1, 1, 9, 1, 4, 1), rfc1902.TimeTicks(123))],
cbFun
)
diff --git a/examples/v3arch/asyncore/manager/cmdgen/spoof-source-address.py b/examples/v3arch/asyncore/manager/cmdgen/spoof-source-address.py
index 953f80e6..229ffdab 100644
--- a/examples/v3arch/asyncore/manager/cmdgen/spoof-source-address.py
+++ b/examples/v3arch/asyncore/manager/cmdgen/spoof-source-address.py
@@ -70,6 +70,7 @@ config.addTargetAddr(
sourceAddress=('1.2.3.4', 0)
)
+
# Error/response receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
@@ -79,21 +80,19 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication,
# SNMPv1 response may contain noSuchName error *and* SNMPv2c exception,
# so we ignore noSuchName error here
elif errorStatus and errorStatus != 2:
- 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 oid, val in varBinds:
print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
+
# Prepare and send a request message
cmdgen.GetCommandGenerator().sendVarBinds(
snmpEngine,
'my-router',
None, '', # contextEngineId, contextName
- [ ((1,3,6,1,2,1,1,1,0), None) ],
+ [((1, 3, 6, 1, 2, 1, 1, 1, 0), None)],
cbFun
)
diff --git a/examples/v3arch/asyncore/manager/cmdgen/usm-sha-aes128.py b/examples/v3arch/asyncore/manager/cmdgen/usm-sha-aes128.py
index 58154ba1..49b20831 100644
--- a/examples/v3arch/asyncore/manager/cmdgen/usm-sha-aes128.py
+++ b/examples/v3arch/asyncore/manager/cmdgen/usm-sha-aes128.py
@@ -49,6 +49,7 @@ config.addTargetAddr(
'my-creds'
)
+
# Error/response receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
@@ -56,21 +57,19 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication,
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 oid, val in varBinds:
print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
+
# Prepare and send a request message
cmdgen.GetCommandGenerator().sendVarBinds(
snmpEngine,
'my-router',
None, '', # contextEngineId, contextName
- [ ((1,3,6,1,2,1,1,1,0), None) ],
+ [((1, 3, 6, 1, 2, 1, 1, 1, 0), None)],
cbFun
)
diff --git a/examples/v3arch/asyncore/manager/cmdgen/usm-sha-none.py b/examples/v3arch/asyncore/manager/cmdgen/usm-sha-none.py
index 45692e4c..807822bf 100644
--- a/examples/v3arch/asyncore/manager/cmdgen/usm-sha-none.py
+++ b/examples/v3arch/asyncore/manager/cmdgen/usm-sha-none.py
@@ -50,6 +50,7 @@ config.addTargetAddr(
'my-creds'
)
+
# Error/response receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
@@ -57,21 +58,19 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication,
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 oid, val in varBinds:
print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
+
# Prepare and send a request message
cmdgen.SetCommandGenerator().sendVarBinds(
snmpEngine,
'my-router',
None, '', # contextEngineId, contextName
- [ ((1,3,6,1,2,1,1,9,1,3,1), rfc1902.OctetString('my new value')) ],
+ [((1, 3, 6, 1, 2, 1, 1, 9, 1, 3, 1), rfc1902.OctetString('my new value'))],
cbFun
)
diff --git a/examples/v3arch/asyncore/manager/cmdgen/v1-get.py b/examples/v3arch/asyncore/manager/cmdgen/v1-get.py
index 9e9019cd..88078331 100644
--- a/examples/v3arch/asyncore/manager/cmdgen/v1-get.py
+++ b/examples/v3arch/asyncore/manager/cmdgen/v1-get.py
@@ -46,6 +46,7 @@ config.addTargetAddr(
'my-creds'
)
+
# Error/response receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
@@ -55,21 +56,19 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication,
# SNMPv1 response may contain noSuchName error *and* SNMPv2c exception,
# so we ignore noSuchName error here
elif errorStatus and errorStatus != 2:
- 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 oid, val in varBinds:
print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
+
# Prepare and send a request message
cmdgen.GetCommandGenerator().sendVarBinds(
snmpEngine,
'my-router',
None, '', # contextEngineId, contextName
- [ ((1,3,6,1,2,1,1,1,0), None) ],
+ [((1, 3, 6, 1, 2, 1, 1, 1, 0), None)],
cbFun
)
diff --git a/examples/v3arch/asyncore/manager/cmdgen/v2c-set.py b/examples/v3arch/asyncore/manager/cmdgen/v2c-set.py
index 7936f174..8a084b20 100644
--- a/examples/v3arch/asyncore/manager/cmdgen/v2c-set.py
+++ b/examples/v3arch/asyncore/manager/cmdgen/v2c-set.py
@@ -48,6 +48,7 @@ config.addTargetAddr(
'my-creds'
)
+
# Error/response receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
@@ -55,21 +56,19 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication,
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 oid, val in varBinds:
print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
+
# Prepare and send a request message
cmdgen.SetCommandGenerator().sendVarBinds(
snmpEngine,
'my-router',
None, '', # contextEngineId, contextName
- [ ((1,3,6,1,2,1,1,9,1,4,1), rfc1902.TimeTicks(123)) ],
+ [((1, 3, 6, 1, 2, 1, 1, 9, 1, 4, 1), rfc1902.TimeTicks(123))],
cbFun
)