diff options
Diffstat (limited to 'examples')
90 files changed, 460 insertions, 457 deletions
diff --git a/examples/hlapi/asyncio/agent/ntforg/default-v1-trap.py b/examples/hlapi/asyncio/agent/ntforg/default-v1-trap.py index 6917ca83..92d3e70e 100644 --- a/examples/hlapi/asyncio/agent/ntforg/default-v1-trap.py +++ b/examples/hlapi/asyncio/agent/ntforg/default-v1-trap.py @@ -23,6 +23,7 @@ Functionally similar to: import asyncio from pysnmp.hlapi.asyncio import * + @asyncio.coroutine def run(): snmpEngine = SnmpEngine() @@ -45,4 +46,5 @@ def run(): snmpEngine.transportDispatcher.closeDispatcher() + asyncio.get_event_loop().run_until_complete(run()) diff --git a/examples/hlapi/asyncio/agent/ntforg/multiple-notifications-at-once.py b/examples/hlapi/asyncio/agent/ntforg/multiple-notifications-at-once.py index 5dfdfdbc..027d3ac6 100644 --- a/examples/hlapi/asyncio/agent/ntforg/multiple-notifications-at-once.py +++ b/examples/hlapi/asyncio/agent/ntforg/multiple-notifications-at-once.py @@ -26,6 +26,7 @@ Functionally similar to: import asyncio from pysnmp.hlapi.asyncio import * + @asyncio.coroutine def sendone(snmpEngine, hostname, notifyType): errorIndication, errorStatus, \ @@ -46,11 +47,12 @@ def sendone(snmpEngine, hostname, notifyType): 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 = SnmpEngine() loop = asyncio.get_event_loop() 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'))]) diff --git a/examples/hlapi/asyncio/manager/cmdgen/multiple-concurrent-queries.py b/examples/hlapi/asyncio/manager/cmdgen/multiple-concurrent-queries.py index 81de80a5..ad9c441b 100644 --- a/examples/hlapi/asyncio/manager/cmdgen/multiple-concurrent-queries.py +++ b/examples/hlapi/asyncio/manager/cmdgen/multiple-concurrent-queries.py @@ -20,6 +20,7 @@ Functionally similar to: import asyncio from pysnmp.hlapi.asyncio import * + @asyncio.coroutine def getone(snmpEngine, hostname): errorIndication, errorStatus, errorIndex, varBinds = yield from getCmd( @@ -34,13 +35,14 @@ def getone(snmpEngine, hostname): print(errorIndication) 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 varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) + snmpEngine = SnmpEngine() diff --git a/examples/hlapi/asyncio/manager/cmdgen/multiple-sequential-queries.py b/examples/hlapi/asyncio/manager/cmdgen/multiple-sequential-queries.py index 0aac7eeb..4a43bc49 100644 --- a/examples/hlapi/asyncio/manager/cmdgen/multiple-sequential-queries.py +++ b/examples/hlapi/asyncio/manager/cmdgen/multiple-sequential-queries.py @@ -20,6 +20,7 @@ Functionally similar to: import asyncio from pysnmp.hlapi.asyncio import * + @asyncio.coroutine def getone(snmpEngine, hostname): errorIndication, errorStatus, errorIndex, varBinds = yield from getCmd( @@ -34,19 +35,21 @@ def getone(snmpEngine, hostname): print(errorIndication) 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 varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) + @asyncio.coroutine def getall(snmpEngine, hostnames): for hostname in hostnames: yield from getone(snmpEngine, hostname) + snmpEngine = SnmpEngine() loop = asyncio.get_event_loop() diff --git a/examples/hlapi/asyncio/manager/cmdgen/v1-get.py b/examples/hlapi/asyncio/manager/cmdgen/v1-get.py index 7757deca..6147706d 100644 --- a/examples/hlapi/asyncio/manager/cmdgen/v1-get.py +++ b/examples/hlapi/asyncio/manager/cmdgen/v1-get.py @@ -18,6 +18,7 @@ Functionally similar to: import asyncio from pysnmp.hlapi.asyncio import * + @asyncio.coroutine def run(): snmpEngine = SnmpEngine() @@ -33,14 +34,15 @@ def run(): print(errorIndication) 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 varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) snmpEngine.transportDispatcher.closeDispatcher() + asyncio.get_event_loop().run_until_complete(run()) diff --git a/examples/hlapi/asyncore/agent/ntforg/multiple-informs-at-once.py b/examples/hlapi/asyncore/agent/ntforg/multiple-informs-at-once.py index d6c21c20..58c5bfb8 100644 --- a/examples/hlapi/asyncore/agent/ntforg/multiple-informs-at-once.py +++ b/examples/hlapi/asyncore/agent/ntforg/multiple-informs-at-once.py @@ -31,8 +31,10 @@ targets = ( ContextData()), ) -def cbFun(snmpEngine, sendRequestHandle, errorIndication, - errorStatus, errorIndex, varBinds, cbctx): + +# noinspection PyUnusedLocal +def cbFun(snmpEngine, sendRequestHandle, errorIndication, + errorStatus, errorIndex, varBinds, cbCtx): if errorIndication: print('Notification %s not sent: %s' % (sendRequestHandle, errorIndication)) elif errorStatus: @@ -43,6 +45,7 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication, for name, val in varBinds: print('%s = %s' % (name.prettyPrint(), val.prettyPrint())) + snmpEngine = SnmpEngine() for authData, transportTarget, contextData in targets: @@ -51,10 +54,10 @@ for authData, transportTarget, contextData in targets: authData, transportTarget, contextData, - 'inform', # NotifyType + 'inform', # NotifyType NotificationType( ObjectIdentity('SNMPv2-MIB', 'coldStart') - ).addVarBinds( ( '1.3.6.1.2.1.1.1.0', 'my name' ) ), + ).addVarBinds(('1.3.6.1.2.1.1.1.0', 'my name')), cbFun=cbFun ) diff --git a/examples/hlapi/asyncore/agent/ntforg/multiple-traps-at-once.py b/examples/hlapi/asyncore/agent/ntforg/multiple-traps-at-once.py index af735726..ae4eaa89 100644 --- a/examples/hlapi/asyncore/agent/ntforg/multiple-traps-at-once.py +++ b/examples/hlapi/asyncore/agent/ntforg/multiple-traps-at-once.py @@ -23,13 +23,13 @@ from pysnmp.hlapi.asyncore import * # ( ( authData, transportTarget ), ... ) targets = ( # 1-st target (SNMPv1 over IPv4/UDP) - ( CommunityData('public', mpModel=0), - UdpTransportTarget(('demo.snmplabs.com', 162)), - ContextData() ), + (CommunityData('public', mpModel=0), + UdpTransportTarget(('demo.snmplabs.com', 162)), + ContextData()), # 2-nd target (SNMPv2c over IPv4/UDP) - ( CommunityData('public'), - UdpTransportTarget(('demo.snmplabs.com', 162)), - ContextData() ), + (CommunityData('public'), + UdpTransportTarget(('demo.snmplabs.com', 162)), + ContextData()), ) snmpEngine = SnmpEngine() @@ -40,12 +40,12 @@ for authData, transportTarget, contextData in targets: authData, transportTarget, contextData, - 'trap', # NotifyType + 'trap', # NotifyType NotificationType( ObjectIdentity('SNMPv2-MIB', 'coldStart') ).addVarBinds( - ( ObjectIdentifier('1.3.6.1.2.1.1.1.0'), - OctetString('my name') ) + (ObjectIdentifier('1.3.6.1.2.1.1.1.0'), + OctetString('my name')) ) ) diff --git a/examples/hlapi/asyncore/agent/ntforg/running-multiple-snmp-engines-at-once.py b/examples/hlapi/asyncore/agent/ntforg/running-multiple-snmp-engines-at-once.py index 9078873e..73cec838 100644 --- a/examples/hlapi/asyncore/agent/ntforg/running-multiple-snmp-engines-at-once.py +++ b/examples/hlapi/asyncore/agent/ntforg/running-multiple-snmp-engines-at-once.py @@ -28,7 +28,7 @@ criterias are also possible. | $ snmpinform -v2c -c public demo.snmplabs.com:1162 123 1.3.6.1.6.3.1.1.5.1 | $ snmpinform -v3 -u usr-md5-des -l authPriv -A authkey1 -X privkey1 demo.snmplabs.com 123 1.3.6.1.6.3.1.1.5.1 -"""# +"""# from pysnmp.hlapi.asyncore import * from pysnmp.carrier.asyncore.dispatch import AsyncoreDispatcher @@ -36,16 +36,18 @@ from pysnmp.carrier.asyncore.dispatch import AsyncoreDispatcher # ( ( authData, transportTarget ), ... ) targets = ( # 1-st target (SNMPv2c over IPv4/UDP) - ( CommunityData('public'), - UdpTransportTarget(('demo.snmplabs.com', 1162)), - ContextData() ), + (CommunityData('public'), + UdpTransportTarget(('demo.snmplabs.com', 1162)), + ContextData()), # 2-nd target (SNMPv3 over IPv4/UDP) - ( UsmUserData('usr-md5-des', 'authkey1', 'privkey1'), - UdpTransportTarget(('demo.snmplabs.com', 162)), - ContextData() ), + (UsmUserData('usr-md5-des', 'authkey1', 'privkey1'), + UdpTransportTarget(('demo.snmplabs.com', 162)), + ContextData()), ) -def cbFun(snmpEngine, sendRequestHandle, errorIndication, + +# noinspection PyUnusedLocal +def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): snmpEngine = cbCtx if errorIndication: @@ -57,12 +59,13 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication, for name, val in varBinds: print('%s = %s' % (name.prettyPrint(), val.prettyPrint())) + # Instantiate the single transport dispatcher object transportDispatcher = AsyncoreDispatcher() # Setup a custom data routing function to select snmpEngine by transportDomain transportDispatcher.registerRoutingCbFun( - lambda td,ta,d: ta[1] % 3 and 'A' or 'B' + lambda td, ta, d: ta[1] % 3 and 'A' or 'B' ) snmpEngineA = SnmpEngine() @@ -73,16 +76,16 @@ snmpEngineB.registerTransportDispatcher(transportDispatcher, 'B') for authData, transportTarget, contextData in targets: snmpEngine = transportTarget.getTransportInfo()[1][1] % 3 and \ - snmpEngineA or snmpEngineB + snmpEngineA or snmpEngineB sendPduHandle = sendNotification( snmpEngine, authData, transportTarget, contextData, - 'inform', # NotifyType + 'inform', # NotifyType NotificationType( ObjectIdentity('SNMPv2-MIB', 'coldStart') - ).addVarBinds( ( '1.3.6.1.2.1.1.1.0', 'my name' ) ), + ).addVarBinds(('1.3.6.1.2.1.1.1.0', 'my name')), cbFun=cbFun, cbCtx=snmpEngine ) diff --git a/examples/hlapi/asyncore/manager/cmdgen/multiple-concurrent-queries.py b/examples/hlapi/asyncore/manager/cmdgen/multiple-concurrent-queries.py index 89e9abf2..2d8bebaa 100644 --- a/examples/hlapi/asyncore/manager/cmdgen/multiple-concurrent-queries.py +++ b/examples/hlapi/asyncore/manager/cmdgen/multiple-concurrent-queries.py @@ -22,37 +22,39 @@ from pysnmp.hlapi.asyncore import * # ( ( authData, transportTarget, varNames ), ... ) targets = ( # 1-st target (SNMPv1 over IPv4/UDP) - ( CommunityData('public', mpModel=0), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), - ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0) )) ), + (CommunityData('public', mpModel=0), + UdpTransportTarget(('demo.snmplabs.com', 161)), + (ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), + ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0)))), # 2-nd target (SNMPv2c over IPv4/UDP) - ( CommunityData('public'), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), - ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0) )) ), + (CommunityData('public'), + UdpTransportTarget(('demo.snmplabs.com', 161)), + (ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), + ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0)))), # 3-nd target (SNMPv2c over IPv4/UDP) - same community and # different transport address. - ( CommunityData('public'), - UdpTransportTarget(('localhost', 161)), - ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysContact', 0)), - ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysName', 0))) ), + (CommunityData('public'), + UdpTransportTarget(('localhost', 161)), + (ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysContact', 0)), + ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysName', 0)))), # 4-nd target (SNMPv3 over IPv4/UDP) - ( UsmUserData('usr-md5-des', 'authkey1', 'privkey1'), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), - ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0) )) ), + (UsmUserData('usr-md5-des', 'authkey1', 'privkey1'), + UdpTransportTarget(('demo.snmplabs.com', 161)), + (ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), + ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0)))), # 5-th target (SNMPv3 over IPv6/UDP) - ( UsmUserData('usr-md5-none', 'authkey1'), - Udp6TransportTarget(('::1', 161)), - ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), - ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0) )) ), + (UsmUserData('usr-md5-none', 'authkey1'), + Udp6TransportTarget(('::1', 161)), + (ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), + ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0)))), # N-th target # ... ) + # Wait for responses or errors -def cbFun(snmpEngine, sendRequestHandle, errorIndication, +# noinspection PyUnusedLocal,PyUnusedLocal +def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): authData, transportTarget = cbCtx print('%s via %s' % (authData, transportTarget)) @@ -61,14 +63,15 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication, return True 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 '?' ) + ) return True - else: + else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) + snmpEngine = SnmpEngine() diff --git a/examples/hlapi/asyncore/manager/cmdgen/pull-mibs-from-multiple-agents-at-once.py b/examples/hlapi/asyncore/manager/cmdgen/pull-mibs-from-multiple-agents-at-once.py index 4eb93317..d87d55c5 100644 --- a/examples/hlapi/asyncore/manager/cmdgen/pull-mibs-from-multiple-agents-at-once.py +++ b/examples/hlapi/asyncore/manager/cmdgen/pull-mibs-from-multiple-agents-at-once.py @@ -21,28 +21,30 @@ from pysnmp.hlapi.asyncore import * # ( ( authData, transportTarget, varNames ), ... ) targets = ( # 1-st target (SNMPv1 over IPv4/UDP) - ( CommunityData('public', mpModel=0), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ( ObjectType(ObjectIdentity('1.3.6.1.2.1')), - ObjectType(ObjectIdentity('1.3.6.1.3.1')) ) ), + (CommunityData('public', mpModel=0), + UdpTransportTarget(('demo.snmplabs.com', 161)), + (ObjectType(ObjectIdentity('1.3.6.1.2.1')), + ObjectType(ObjectIdentity('1.3.6.1.3.1')))), # 2-nd target (SNMPv2c over IPv4/UDP) - ( CommunityData('public'), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ( ObjectType(ObjectIdentity('1.3.6.1.4.1')), ) ), + (CommunityData('public'), + UdpTransportTarget(('demo.snmplabs.com', 161)), + (ObjectType(ObjectIdentity('1.3.6.1.4.1')),)), # 3-nd target (SNMPv3 over IPv4/UDP) - ( UsmUserData('usr-md5-des', 'authkey1', 'privkey1'), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'system')), ) ), + (UsmUserData('usr-md5-des', 'authkey1', 'privkey1'), + UdpTransportTarget(('demo.snmplabs.com', 161)), + (ObjectType(ObjectIdentity('SNMPv2-MIB', 'system')),)), # 4-th target (SNMPv3 over IPv6/UDP) - ( UsmUserData('usr-md5-none', 'authkey1'), - Udp6TransportTarget(('::1', 161)), - ( ObjectType(ObjectIdentity('IF-MIB', 'ifTable')), ) ) + (UsmUserData('usr-md5-none', 'authkey1'), + Udp6TransportTarget(('::1', 161)), + (ObjectType(ObjectIdentity('IF-MIB', 'ifTable')),)) # N-th target # ... ) + # Wait for responses or errors, submit GETNEXT requests for further OIDs -def cbFun(snmpEngine, sendRequestHandle, errorIndication, +# noinspection PyUnusedLocal,PyUnusedLocal +def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBindTable, cbCtx): (authData, transportTarget) = cbCtx print('%s via %s' % (authData, transportTarget)) @@ -50,18 +52,16 @@ 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: for varBind in varBindRow: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) + + return True # continue table retrieval - return True # continue table retrieval snmpEngine = SnmpEngine() diff --git a/examples/hlapi/asyncore/manager/cmdgen/pull-whole-mib.py b/examples/hlapi/asyncore/manager/cmdgen/pull-whole-mib.py index 19b397f6..c29c3559 100644 --- a/examples/hlapi/asyncore/manager/cmdgen/pull-whole-mib.py +++ b/examples/hlapi/asyncore/manager/cmdgen/pull-whole-mib.py @@ -17,33 +17,32 @@ Functionally similar to: """# from pysnmp.hlapi.asyncore import * -def cbFun(snmpEngine, sendRequestHandle, errorIndication, + +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal +def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBindTable, cbCtx): if 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: for varBind in varBindRow: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) return True # request lower layers to do GETNEXT and call us back + snmpEngine = SnmpEngine() nextCmd(snmpEngine, - UsmUserData('usr-md5-none', 'authkey1'), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ContextData(), - ObjectType(ObjectIdentity('SNMPv2-MIB', 'system')), - ObjectType(ObjectIdentity('IF-MIB', 'ifTable')), - cbFun=cbFun) + UsmUserData('usr-md5-none', 'authkey1'), + UdpTransportTarget(('demo.snmplabs.com', 161)), + ContextData(), + ObjectType(ObjectIdentity('SNMPv2-MIB', 'system')), + ObjectType(ObjectIdentity('IF-MIB', 'ifTable')), + cbFun=cbFun) snmpEngine.transportDispatcher.runDispatcher() 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 b5a17a64..ce8613a6 100644 --- a/examples/hlapi/asyncore/manager/cmdgen/query-multiple-snmp-engines.py +++ b/examples/hlapi/asyncore/manager/cmdgen/query-multiple-snmp-engines.py @@ -35,51 +35,48 @@ from pysnmp.carrier.asyncore.dispatch import AsyncoreDispatcher # ( ( authData, transportTarget, varNames ), ... ) targets = ( # 1-st target (SNMPv1 over IPv4/UDP) - ( CommunityData('public', mpModel=0), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), - ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0) )) ), + (CommunityData('public', mpModel=0), + UdpTransportTarget(('demo.snmplabs.com', 161)), + (ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), + ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0)))), # 2-nd target (SNMPv2c over IPv4/UDP) - ( CommunityData('public'), - UdpTransportTarget(('demo.snmplabs.com', 1161)), - ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), - ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0) )) ), + (CommunityData('public'), + UdpTransportTarget(('demo.snmplabs.com', 1161)), + (ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), + ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0)))), # 3-nd target (SNMPv3 over IPv4/UDP) - ( UsmUserData('usr-md5-des', 'authkey1', 'privkey1'), - UdpTransportTarget(('demo.snmplabs.com', 2161)), - ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), - ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0) )) ) + (UsmUserData('usr-md5-des', 'authkey1', 'privkey1'), + UdpTransportTarget(('demo.snmplabs.com', 2161)), + (ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), + ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0)))) # N-th target # ... ) + # Wait for responses or errors +# noinspection PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): (snmpEngine, authData, transportTarget) = cbCtx - print('snmpEngine %s: %s via %s' % - (snmpEngine.snmpEngineID.prettyPrint(), authData, transportTarget) - ) + print('snmpEngine %s: %s via %s' % (snmpEngine.snmpEngineID.prettyPrint(), authData, transportTarget)) if errorIndication: print(errorIndication) - return 1 + return True elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) - return 1 + print('%s at %s' % (errorStatus.prettyPrint(), errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) + return True else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) + # Instantiate the single transport dispatcher object transportDispatcher = AsyncoreDispatcher() # Setup a custom data routing function to select snmpEngine by transportDomain transportDispatcher.registerRoutingCbFun( - lambda td,ta,d: ta[1] % 3 and 'A' or 'B' + lambda td, ta, d: ta[1] % 3 and 'A' or 'B' ) snmpEngineA = SnmpEngine() @@ -90,7 +87,7 @@ snmpEngineB.registerTransportDispatcher(transportDispatcher, 'B') for authData, transportTarget, varBinds in targets: snmpEngine = transportTarget.getTransportInfo()[1][1] % 3 and \ - snmpEngineA or snmpEngineB + snmpEngineA or snmpEngineB getCmd(snmpEngine, authData, transportTarget, ContextData(), *varBinds, **dict(cbFun=cbFun, cbCtx=(snmpEngine, authData, transportTarget))) diff --git a/examples/hlapi/asyncore/manager/cmdgen/v2c-get.py b/examples/hlapi/asyncore/manager/cmdgen/v2c-get.py index f46ae515..29748a61 100644 --- a/examples/hlapi/asyncore/manager/cmdgen/v2c-get.py +++ b/examples/hlapi/asyncore/manager/cmdgen/v2c-get.py @@ -16,21 +16,20 @@ Functionally similar to: """# from pysnmp.hlapi.asyncore import * -def cbFun(snmpEngine, sendRequestHandle, errorIndication, + +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal +def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): if 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: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) + snmpEngine = SnmpEngine() diff --git a/examples/hlapi/asyncore/sync/agent/ntforg/custom-contextengineid.py b/examples/hlapi/asyncore/sync/agent/ntforg/custom-contextengineid.py index 0c02b962..6c4e7adc 100644 --- a/examples/hlapi/asyncore/sync/agent/ntforg/custom-contextengineid.py +++ b/examples/hlapi/asyncore/sync/agent/ntforg/custom-contextengineid.py @@ -34,11 +34,8 @@ errorIndication, errorStatus, errorIndex, varBinds = next( 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])) diff --git a/examples/hlapi/asyncore/sync/agent/ntforg/custom-contextname.py b/examples/hlapi/asyncore/sync/agent/ntforg/custom-contextname.py index 096a83d1..729c9b83 100644 --- a/examples/hlapi/asyncore/sync/agent/ntforg/custom-contextname.py +++ b/examples/hlapi/asyncore/sync/agent/ntforg/custom-contextname.py @@ -34,11 +34,8 @@ errorIndication, errorStatus, errorIndex, varBinds = next( 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])) diff --git a/examples/hlapi/asyncore/sync/agent/ntforg/custom-v1-trap.py b/examples/hlapi/asyncore/sync/agent/ntforg/custom-v1-trap.py index 768ef02a..8693f13f 100644 --- a/examples/hlapi/asyncore/sync/agent/ntforg/custom-v1-trap.py +++ b/examples/hlapi/asyncore/sync/agent/ntforg/custom-v1-trap.py @@ -25,19 +25,20 @@ Functionally similar to: from pysnmp.hlapi import * errorIndication, errorStatus, errorIndex, varBinds = next( - sendNotification(SnmpEngine(), - CommunityData('public', mpModel=0), - UdpTransportTarget(('demo.snmplabs.com', 162)), - ContextData(), - 'trap', - NotificationType( - ObjectIdentity('1.3.6.1.4.1.20408.4.1.1.2.0.432'), - ).addVarBinds( - ('1.3.6.1.2.1.1.3.0', 12345), - ('1.3.6.1.6.3.18.1.3.0', '127.0.0.1'), - ('1.3.6.1.6.3.1.1.4.3.0', '1.3.6.1.4.1.20408.4.1.1.2'), - ('1.3.6.1.2.1.1.1.0', OctetString('my system')) - ) + sendNotification( + SnmpEngine(), + CommunityData('public', mpModel=0), + UdpTransportTarget(('demo.snmplabs.com', 162)), + ContextData(), + 'trap', + NotificationType( + ObjectIdentity('1.3.6.1.4.1.20408.4.1.1.2.0.432'), + ).addVarBinds( + ('1.3.6.1.2.1.1.3.0', 12345), + ('1.3.6.1.6.3.18.1.3.0', '127.0.0.1'), + ('1.3.6.1.6.3.1.1.4.3.0', '1.3.6.1.4.1.20408.4.1.1.2'), + ('1.3.6.1.2.1.1.1.0', OctetString('my system')) + ) ) ) if errorIndication: diff --git a/examples/hlapi/asyncore/sync/agent/ntforg/default-v1-trap.py b/examples/hlapi/asyncore/sync/agent/ntforg/default-v1-trap.py index 9141cc5e..18cc2c77 100644 --- a/examples/hlapi/asyncore/sync/agent/ntforg/default-v1-trap.py +++ b/examples/hlapi/asyncore/sync/agent/ntforg/default-v1-trap.py @@ -23,18 +23,20 @@ Functionally similar to: from pysnmp.hlapi import * errorIndication, errorStatus, errorIndex, varBinds = next( - sendNotification(SnmpEngine(), - CommunityData('public', mpModel=0), - UdpTransportTarget(('demo.snmplabs.com', 162)), - ContextData(), - 'trap', - NotificationType( - ObjectIdentity('1.3.6.1.6.3.1.1.5.2') - ).addVarBinds( - ('1.3.6.1.6.3.1.1.4.3.0', '1.3.6.1.4.1.20408.4.1.1.2'), - ('1.3.6.1.2.1.1.1.0', OctetString('my system')) - ) + sendNotification( + SnmpEngine(), + CommunityData('public', mpModel=0), + UdpTransportTarget(('demo.snmplabs.com', 162)), + ContextData(), + 'trap', + NotificationType( + ObjectIdentity('1.3.6.1.6.3.1.1.5.2') + ).addVarBinds( + ('1.3.6.1.6.3.1.1.4.3.0', '1.3.6.1.4.1.20408.4.1.1.2'), + ('1.3.6.1.2.1.1.1.0', OctetString('my system')) + ) ) ) + if errorIndication: print(errorIndication) diff --git a/examples/hlapi/asyncore/sync/agent/ntforg/send-notification-with-additional-varbinds.py b/examples/hlapi/asyncore/sync/agent/ntforg/send-notification-with-additional-varbinds.py index 8ffa8cec..46f3c5c1 100644 --- a/examples/hlapi/asyncore/sync/agent/ntforg/send-notification-with-additional-varbinds.py +++ b/examples/hlapi/asyncore/sync/agent/ntforg/send-notification-with-additional-varbinds.py @@ -19,27 +19,25 @@ Functionally similar to: from pysnmp.hlapi import * errorIndication, errorStatus, errorIndex, varBinds = next( - sendNotification(SnmpEngine(), - CommunityData('public'), - UdpTransportTarget(('demo.snmplabs.com', 162)), - ContextData(), - 'inform', - NotificationType( - ObjectIdentity('SNMPv2-MIB', 'coldStart') - ).addVarBinds( - ObjectType(ObjectIdentity('SNMPv2-MIB','sysName',0), - 'my system') - )) + sendNotification( + SnmpEngine(), + CommunityData('public'), + UdpTransportTarget(('demo.snmplabs.com', 162)), + ContextData(), + 'inform', + NotificationType( + ObjectIdentity('SNMPv2-MIB', 'coldStart') + ).addVarBinds( + ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysName', 0), 'my system') + ) + ) ) 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])) diff --git a/examples/hlapi/asyncore/sync/agent/ntforg/v2c-trap-with-notification-objects.py b/examples/hlapi/asyncore/sync/agent/ntforg/v2c-trap-with-notification-objects.py index 5f59738a..5681d28c 100644 --- a/examples/hlapi/asyncore/sync/agent/ntforg/v2c-trap-with-notification-objects.py +++ b/examples/hlapi/asyncore/sync/agent/ntforg/v2c-trap-with-notification-objects.py @@ -21,18 +21,19 @@ Functionally similar to: from pysnmp.hlapi import * errorIndication, errorStatus, errorIndex, varBinds = next( - sendNotification(SnmpEngine(), - CommunityData('public'), - UdpTransportTarget(('demo.snmplabs.com', 162)), - ContextData(), - 'trap', - NotificationType( - ObjectIdentity('IF-MIB', 'linkUp'), - instanceIndex=(123,), - objects={('IF-MIB', 'ifIndex'): 123, - ('IF-MIB', 'ifAdminStatus'): 'up', - ('IF-MIB', 'ifOperStatus'): 'up'} - ) + sendNotification( + SnmpEngine(), + CommunityData('public'), + UdpTransportTarget(('demo.snmplabs.com', 162)), + ContextData(), + 'trap', + NotificationType( + ObjectIdentity('IF-MIB', 'linkUp'), + instanceIndex=(123,), + objects={('IF-MIB', 'ifIndex'): 123, + ('IF-MIB', 'ifAdminStatus'): 'up', + ('IF-MIB', 'ifOperStatus'): 'up'} + ) ) ) diff --git a/examples/hlapi/asyncore/sync/agent/ntforg/v3-inform.py b/examples/hlapi/asyncore/sync/agent/ntforg/v3-inform.py index 638dd242..46153978 100644 --- a/examples/hlapi/asyncore/sync/agent/ntforg/v3-inform.py +++ b/examples/hlapi/asyncore/sync/agent/ntforg/v3-inform.py @@ -19,27 +19,25 @@ Functionally similar to: from pysnmp.hlapi import * errorIndication, errorStatus, errorIndex, varBinds = next( - sendNotification(SnmpEngine(), - UsmUserData('usr-md5-des', 'authkey1', 'privkey1'), - UdpTransportTarget(('demo.snmplabs.com', 162)), - ContextData(), - 'inform', - NotificationType( - ObjectIdentity('1.3.6.1.6.3.1.1.5.2') - ).addVarBinds( - ObjectType(ObjectIdentity('1.3.6.1.2.1.1.5.0'), - 'system name') - )) + sendNotification( + SnmpEngine(), + UsmUserData('usr-md5-des', 'authkey1', 'privkey1'), + UdpTransportTarget(('demo.snmplabs.com', 162)), + ContextData(), + 'inform', + NotificationType( + ObjectIdentity('1.3.6.1.6.3.1.1.5.2') + ).addVarBinds( + ObjectType(ObjectIdentity('1.3.6.1.2.1.1.5.0'), 'system name') + ) + ) ) 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])) diff --git a/examples/hlapi/asyncore/sync/agent/ntforg/v3-trap.py b/examples/hlapi/asyncore/sync/agent/ntforg/v3-trap.py index 2f402c7e..836e8d50 100644 --- a/examples/hlapi/asyncore/sync/agent/ntforg/v3-trap.py +++ b/examples/hlapi/asyncore/sync/agent/ntforg/v3-trap.py @@ -25,17 +25,17 @@ Functionally similar to: from pysnmp.hlapi import * errorIndication, errorStatus, errorIndex, varBinds = next( - sendNotification(SnmpEngine(OctetString(hexValue='8000000001020304')), - UsmUserData('usr-sha-aes128', 'authkey1', 'privkey1', - authProtocol=usmHMACSHAAuthProtocol, - privProtocol=usmAesCfb128Protocol), - UdpTransportTarget(('demo.snmplabs.com', 162)), - ContextData(), - 'trap', - NotificationType( - ObjectIdentity('SNMPv2-MIB', 'authenticationFailure') - ) + sendNotification( + SnmpEngine(OctetString(hexValue='8000000001020304')), + UsmUserData('usr-sha-aes128', 'authkey1', 'privkey1', + authProtocol=usmHMACSHAAuthProtocol, + privProtocol=usmAesCfb128Protocol), + UdpTransportTarget(('demo.snmplabs.com', 162)), + ContextData(), + 'trap', + NotificationType(ObjectIdentity('SNMPv2-MIB', 'authenticationFailure')) ) ) + if errorIndication: print(errorIndication) diff --git a/examples/hlapi/asyncore/sync/manager/cmdgen/coerce-set-value-to-mib-spec.py b/examples/hlapi/asyncore/sync/manager/cmdgen/coerce-set-value-to-mib-spec.py index ab2df92c..b6fb879e 100644 --- a/examples/hlapi/asyncore/sync/manager/cmdgen/coerce-set-value-to-mib-spec.py +++ b/examples/hlapi/asyncore/sync/manager/cmdgen/coerce-set-value-to-mib-spec.py @@ -11,8 +11,7 @@ Send SNMP SET request using the following options: Functionally similar to: -| $ snmpset -v2c -c public demo.snmplabs.com SNMPv2-MIB::sysDescr.0 \ -| = "new system name" +| $ snmpset -v2c -c public demo.snmplabs.com SNMPv2-MIB::sysDescr.0 = "new system name" """# from pysnmp.hlapi import * @@ -29,11 +28,8 @@ errorIndication, errorStatus, errorIndex, varBinds = next( 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])) diff --git a/examples/hlapi/asyncore/sync/manager/cmdgen/custom-asn1-mib-search-path.py b/examples/hlapi/asyncore/sync/manager/cmdgen/custom-asn1-mib-search-path.py index 22fbe6de..f25fafe4 100644 --- a/examples/hlapi/asyncore/sync/manager/cmdgen/custom-asn1-mib-search-path.py +++ b/examples/hlapi/asyncore/sync/manager/cmdgen/custom-asn1-mib-search-path.py @@ -12,8 +12,7 @@ Send SNMP GET request using the following options: Functionally similar to: -| $ snmpget -v2c -c public -M /usr/share/snmp demo.snmplabs.com \ -| IF-MIB::ifInOctets.1 +| $ snmpget -v2c -c public -M /usr/share/snmp demo.snmplabs.com IF-MIB::ifInOctets.1 """# from pysnmp.hlapi import * @@ -23,17 +22,15 @@ errorIndication, errorStatus, errorIndex, varBinds = next( CommunityData('public'), UdpTransportTarget(('demo.snmplabs.com', 161)), ContextData(), - ObjectType(ObjectIdentity('IF-MIB', 'ifInOctets', 1).addAsn1MibSource('file:///usr/share/snmp', 'http://mibs.snmplabs.com/asn1/@mib@'))) + ObjectType(ObjectIdentity('IF-MIB', 'ifInOctets', 1).addAsn1MibSource('file:///usr/share/snmp', + 'http://mibs.snmplabs.com/asn1/@mib@'))) ) 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])) diff --git a/examples/hlapi/asyncore/sync/manager/cmdgen/custom-contextengineid-and-contextname.py b/examples/hlapi/asyncore/sync/manager/cmdgen/custom-contextengineid-and-contextname.py index 1244583d..497af602 100644 --- a/examples/hlapi/asyncore/sync/manager/cmdgen/custom-contextengineid-and-contextname.py +++ b/examples/hlapi/asyncore/sync/manager/cmdgen/custom-contextengineid-and-contextname.py @@ -14,10 +14,7 @@ Send SNMP SET request using the following options: Functionally similar to: -| $ snmpset -v3 -u usr-md5-des -l authPriv -A authkey1 -X privkey1 \ -| -E 80004fb805636c6f75644dab22cc -n a172334d7d97871b72241397f713fa12 \ -| demo.snmplabs.com \ -| SNMPv2-MIB::sysORDescr.1 = "new system name" +| $ snmpset -v3 -u usr-md5-des -l authPriv -A authkey1 -X privkey1 -E 80004fb805636c6f75644dab22cc -n a172334d7d97871b72241397f713fa12 demo.snmplabs.com SNMPv2-MIB::sysORDescr.1 = "new system name" """# from pysnmp.hlapi import * @@ -28,18 +25,14 @@ errorIndication, errorStatus, errorIndex, varBinds = next( UdpTransportTarget(('demo.snmplabs.com', 161)), ContextData(contextEngineId=OctetString(hexValue='80004fb805636c6f75644dab22cc'), contextName='da761cfc8c94d3aceef4f60f049105ba'), - ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysORDescr', 1), - 'new system name')) + ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysORDescr', 1), 'new system name')) ) 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])) diff --git a/examples/hlapi/asyncore/sync/manager/cmdgen/custom-contextengineid.py b/examples/hlapi/asyncore/sync/manager/cmdgen/custom-contextengineid.py index ea97c59d..6435a5d5 100644 --- a/examples/hlapi/asyncore/sync/manager/cmdgen/custom-contextengineid.py +++ b/examples/hlapi/asyncore/sync/manager/cmdgen/custom-contextengineid.py @@ -13,9 +13,7 @@ Send SNMP GET request using the following options: Functionally similar to: -| $ snmpset -v3 -u usr-md5-des -l authPriv -A authkey1 -X privkey1 \ -| -E 80004fb805636c6f75644dab22cc demo.snmplabs.com \ -| SNMPv2-MIB::sysORDescr.1 = "new system name" +| $ snmpset -v3 -u usr-md5-des -l authPriv -A authkey1 -X privkey1 -E 80004fb805636c6f75644dab22cc demo.snmplabs.com SNMPv2-MIB::sysORDescr.1 = "new system name" """# from pysnmp.hlapi import * @@ -26,18 +24,14 @@ errorIndication, errorStatus, errorIndex, varBinds = next( securityEngineId=OctetString(hexValue='80004fb805636c6f75644dab22cc')), UdpTransportTarget(('demo.snmplabs.com', 161)), ContextData(), - ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysName', 0), - 'new system name')) + ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysName', 0), 'new system name')) ) 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])) diff --git a/examples/hlapi/asyncore/sync/manager/cmdgen/custom-pysnmp-mibs-search-path.py b/examples/hlapi/asyncore/sync/manager/cmdgen/custom-pysnmp-mibs-search-path.py index 42b1df6c..26b8954a 100644 --- a/examples/hlapi/asyncore/sync/manager/cmdgen/custom-pysnmp-mibs-search-path.py +++ b/examples/hlapi/asyncore/sync/manager/cmdgen/custom-pysnmp-mibs-search-path.py @@ -14,32 +14,31 @@ 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 TCP-MIB::tcpConnTable +| $ snmpbulkwalk -v3 -lnoAuthNoPriv -u usr-none-none -Cn0 -Cr50 demo.snmplabs.com TCP-MIB::tcpConnTable """# from pysnmp.hlapi import * -for errorIndication, \ - errorStatus, errorIndex, \ - varBinds in bulkCmd(SnmpEngine(), - UsmUserData('usr-none-none'), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ContextData(), - 0, 50, - ObjectType(ObjectIdentity('TCP-MIB', 'tcpConnTable').addMibSource('/opt/mibs/pysnmp').addMibSource('python_packaged_mibs')), - lexicographicMode=False): +for (errorIndication, + errorStatus, + errorIndex, + varBinds) in bulkCmd(SnmpEngine(), + UsmUserData('usr-none-none'), + UdpTransportTarget(('demo.snmplabs.com', 161)), + ContextData(), + 0, 50, + ObjectType( + ObjectIdentity('TCP-MIB', 'tcpConnTable').addMibSource('/opt/mibs/pysnmp').addMibSource('python_packaged_mibs') + ), + lexicographicMode=False): 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 '?')) break else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) diff --git a/examples/hlapi/asyncore/sync/manager/cmdgen/custom-timeout-and-retries.py b/examples/hlapi/asyncore/sync/manager/cmdgen/custom-timeout-and-retries.py index cfa274fe..d70a322f 100644 --- a/examples/hlapi/asyncore/sync/manager/cmdgen/custom-timeout-and-retries.py +++ b/examples/hlapi/asyncore/sync/manager/cmdgen/custom-timeout-and-retries.py @@ -43,11 +43,8 @@ errorIndication, errorStatus, errorIndex, varBinds = next( 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])) diff --git a/examples/hlapi/asyncore/sync/manager/cmdgen/custom-v3-security-name.py b/examples/hlapi/asyncore/sync/manager/cmdgen/custom-v3-security-name.py index 4346b26d..8e541f7b 100644 --- a/examples/hlapi/asyncore/sync/manager/cmdgen/custom-v3-security-name.py +++ b/examples/hlapi/asyncore/sync/manager/cmdgen/custom-v3-security-name.py @@ -28,11 +28,8 @@ errorIndication, errorStatus, errorIndex, varBinds = next( 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])) diff --git a/examples/hlapi/asyncore/sync/manager/cmdgen/fetch-variables-over-ipv6.py b/examples/hlapi/asyncore/sync/manager/cmdgen/fetch-variables-over-ipv6.py index d4316594..9bc76446 100644 --- a/examples/hlapi/asyncore/sync/manager/cmdgen/fetch-variables-over-ipv6.py +++ b/examples/hlapi/asyncore/sync/manager/cmdgen/fetch-variables-over-ipv6.py @@ -11,11 +11,7 @@ Send SNMP GET request using the following options: Functionally similar to: -| $ snmpget -v3 -l authPriv -u usr-md5-des -A authkey1 -X privkey1 \ -| udp6:[::1]:161 \ -| 1.3.6.1.2.1.1.1.0 \ -| 1.3.6.1.2.1.1.2.0 \ -| 1.3.6.1.2.1.1.3.0 +| $ snmpget -v3 -l authPriv -u usr-md5-des -A authkey1 -X privkey1 udp6:[::1]:161 1.3.6.1.2.1.1.1.0 1.3.6.1.2.1.1.2.0 1.3.6.1.2.1.1.3.0 """# from pysnmp.hlapi import * @@ -32,11 +28,8 @@ errorIndication, errorStatus, errorIndex, varBinds = next( 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])) diff --git a/examples/hlapi/asyncore/sync/manager/cmdgen/get-table-object-by-index.py b/examples/hlapi/asyncore/sync/manager/cmdgen/get-table-object-by-index.py index fc8a8822..ed5d8351 100644 --- a/examples/hlapi/asyncore/sync/manager/cmdgen/get-table-object-by-index.py +++ b/examples/hlapi/asyncore/sync/manager/cmdgen/get-table-object-by-index.py @@ -12,9 +12,7 @@ Send SNMP GET request using the following options: Functionally similar to: -| $ snmpget -v3 -l authPriv -u usr-md5-des -A authkey1 -X privkey1 \ -| demo.snmplabs.com \ -| IF-MIB::ifInOctets.1 IF-MIB::ifOutOctets.1 +| $ snmpget -v3 -l authPriv -u usr-md5-des -A authkey1 -X privkey1 demo.snmplabs.com IF-MIB::ifInOctets.1 IF-MIB::ifOutOctets.1 """# from pysnmp.hlapi import * @@ -31,11 +29,8 @@ errorIndication, errorStatus, errorIndex, varBinds = next( 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])) diff --git a/examples/hlapi/asyncore/sync/manager/cmdgen/get-table-object-by-multiple-indices.py b/examples/hlapi/asyncore/sync/manager/cmdgen/get-table-object-by-multiple-indices.py index 5d0621db..672aea93 100644 --- a/examples/hlapi/asyncore/sync/manager/cmdgen/get-table-object-by-multiple-indices.py +++ b/examples/hlapi/asyncore/sync/manager/cmdgen/get-table-object-by-multiple-indices.py @@ -11,10 +11,7 @@ Send SNMP GET request using the following options: Functionally similar to: -| $ snmpget -v3 -l authPriv -u usr-md5-des -A authkey1 -X privkey1 \ -| -a SHA -x AES \ -| demo.snmplabs.com \ -| TCP-MIB::tcpConnLocalAddress."0.0.0.0".22."0.0.0.0".0 +| $ snmpget -v3 -l authPriv -u usr-md5-des -A authkey1 -X privkey1 -a SHA -x AES demo.snmplabs.com TCP-MIB::tcpConnLocalAddress."0.0.0.0".22."0.0.0.0".0 """# from pysnmp.hlapi import * @@ -23,24 +20,20 @@ errorIndication, errorStatus, errorIndex, varBinds = next( getCmd(SnmpEngine(), UsmUserData('usr-sha-aes128', 'authkey1', 'privkey1', authProtocol=usmHMACSHAAuthProtocol, - privProtocol=usmAesCfb128Protocol ), + privProtocol=usmAesCfb128Protocol), UdpTransportTarget(('demo.snmplabs.com', 161)), ContextData(), ObjectType(ObjectIdentity('TCP-MIB', 'tcpConnLocalAddress', '0.0.0.0', 22, - '0.0.0.0', 0)) - ) + '0.0.0.0', 0))) ) 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])) diff --git a/examples/hlapi/asyncore/sync/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py b/examples/hlapi/asyncore/sync/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py index 6b18d422..499c9b02 100644 --- a/examples/hlapi/asyncore/sync/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py +++ b/examples/hlapi/asyncore/sync/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py @@ -13,36 +13,30 @@ Send a series of SNMP GETBULK requests using the following options: Functionally similar to: -| $ snmpbulkwalk -v3 -lauthPriv -u usr-md5-des -A authkey1 -X privkey1 \ -| -Cn1, -Cr25 \ -| demo.snmplabs.com \ -| IP-MIB::ipAdEntAddr \ -| IP-MIB::ipAddrEntry +| $ snmpbulkwalk -v3 -lauthPriv -u usr-md5-des -A authkey1 -X privkey1 -Cn1, -Cr25 demo.snmplabs.com IP-MIB::ipAdEntAddr IP-MIB::ipAddrEntry """# from pysnmp.hlapi import * -for errorIndication, \ - errorStatus, errorIndex, \ - varBinds in bulkCmd(SnmpEngine(), - UsmUserData('usr-md5-des', 'authkey1', 'privkey1'), - Udp6TransportTarget(('::1', 161)), - ContextData(), - 1, 25, - ObjectType(ObjectIdentity('IP-MIB', 'ipAdEntAddr')), - ObjectType(ObjectIdentity('IP-MIB', 'ipAddrEntry')), - lexicographicMode=False): +for (errorIndication, + errorStatus, + errorIndex, + varBinds) in bulkCmd(SnmpEngine(), + UsmUserData('usr-md5-des', 'authkey1', 'privkey1'), + Udp6TransportTarget(('::1', 161)), + ContextData(), + 1, 25, + ObjectType(ObjectIdentity('IP-MIB', 'ipAdEntAddr')), + ObjectType(ObjectIdentity('IP-MIB', 'ipAddrEntry')), + lexicographicMode=False): 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 '?')) break else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) diff --git a/examples/hlapi/asyncore/sync/manager/cmdgen/getbulk-limit-number-of-packets.py b/examples/hlapi/asyncore/sync/manager/cmdgen/getbulk-limit-number-of-packets.py index 51468089..dd94650c 100644 --- a/examples/hlapi/asyncore/sync/manager/cmdgen/getbulk-limit-number-of-packets.py +++ b/examples/hlapi/asyncore/sync/manager/cmdgen/getbulk-limit-number-of-packets.py @@ -13,32 +13,29 @@ 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 """# from pysnmp.hlapi import * -for errorIndication, \ - errorStatus, errorIndex, \ - varBinds in bulkCmd(SnmpEngine(), - UsmUserData('usr-none-none'), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ContextData(), - 0, 50, - ObjectType(ObjectIdentity('SNMPv2-MIB', 'system')), - maxCalls=10): +for (errorIndication, + errorStatus, + errorIndex, + varBinds) in bulkCmd(SnmpEngine(), + UsmUserData('usr-none-none'), + UdpTransportTarget(('demo.snmplabs.com', 161)), + ContextData(), + 0, 50, + ObjectType(ObjectIdentity('SNMPv2-MIB', 'system')), + maxCalls=10): 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 '?')) break else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) diff --git a/examples/hlapi/asyncore/sync/manager/cmdgen/getbulk-limit-number-of-variables.py b/examples/hlapi/asyncore/sync/manager/cmdgen/getbulk-limit-number-of-variables.py index ef95f5a8..fa39086b 100644 --- a/examples/hlapi/asyncore/sync/manager/cmdgen/getbulk-limit-number-of-variables.py +++ b/examples/hlapi/asyncore/sync/manager/cmdgen/getbulk-limit-number-of-variables.py @@ -14,33 +14,29 @@ Send a series of SNMP GETBULK requests using the following options: Functionally similar to: -| $ snmpbulkwalk -v2c -c public demo.snmplabs.com \ -| -Cn0 -Cr25 \ -| 1.3.6.1.2.1.2.2 1.3.6.1.2.1.2.3 +| $ snmpbulkwalk -v2c -c public demo.snmplabs.com -Cn0 -Cr25 1.3.6.1.2.1.2.2 1.3.6.1.2.1.2.3 """# from pysnmp.hlapi import * -for errorIndication, \ - errorStatus, errorIndex, \ - varBinds in bulkCmd(SnmpEngine(), - CommunityData('public'), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ContextData(), - 0, 25, - ObjectType(ObjectIdentity('1.3.6.1.2.1.2.2')), - ObjectType(ObjectIdentity('1.3.6.1.2.1.2.3')), - lexicographicMode=False, maxRows=20): +for (errorIndication, + errorStatus, + errorIndex, + varBinds) in bulkCmd(SnmpEngine(), + CommunityData('public'), + UdpTransportTarget(('demo.snmplabs.com', 161)), + ContextData(), + 0, 25, + ObjectType(ObjectIdentity('1.3.6.1.2.1.2.2')), + ObjectType(ObjectIdentity('1.3.6.1.2.1.2.3')), + lexicographicMode=False, maxRows=20): 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 '?')) break else: for varBind in varBinds: diff --git a/examples/hlapi/asyncore/sync/manager/cmdgen/getnext-limit-number-of-variables.py b/examples/hlapi/asyncore/sync/manager/cmdgen/getnext-limit-number-of-variables.py index 9536ebb5..f9fd70c1 100644 --- a/examples/hlapi/asyncore/sync/manager/cmdgen/getnext-limit-number-of-variables.py +++ b/examples/hlapi/asyncore/sync/manager/cmdgen/getnext-limit-number-of-variables.py @@ -13,34 +13,30 @@ Send a series of SNMP GETNEXT requests using the following options: Functionally similar to: -| $ snmpwalk -v3 -lauthPriv -u usr-sha-aes128 -A authkey1 -X privkey1 \ -| -a MD5 -x AES demo.snmplabs.com \ -| SNMPv2-MIB::system +| $ snmpwalk -v3 -lauthPriv -u usr-sha-aes128 -A authkey1 -X privkey1 -a MD5 -x AES demo.snmplabs.com SNMPv2-MIB::system """# from pysnmp.hlapi import * -for errorIndication, \ - errorStatus, errorIndex, \ - varBinds in nextCmd(SnmpEngine(), - UsmUserData('usr-sha-aes128', 'authkey1', 'privkey1', - authProtocol=usmHMACSHAAuthProtocol, - privProtocol=usmAesCfb128Protocol), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ContextData(), - ObjectType(ObjectIdentity('SNMPv2-MIB')), - maxRows=100, ignoreNonIncreasingOid=True): +for (errorIndication, + errorStatus, + errorIndex, + varBinds) in nextCmd(SnmpEngine(), + UsmUserData('usr-sha-aes128', 'authkey1', 'privkey1', + authProtocol=usmHMACSHAAuthProtocol, + privProtocol=usmAesCfb128Protocol), + UdpTransportTarget(('demo.snmplabs.com', 161)), + ContextData(), + ObjectType(ObjectIdentity('SNMPv2-MIB')), + maxRows=100, ignoreNonIncreasingOid=True): 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 '?')) break else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) diff --git a/examples/hlapi/asyncore/sync/manager/cmdgen/getnext-multiple-oids-to-eom.py b/examples/hlapi/asyncore/sync/manager/cmdgen/getnext-multiple-oids-to-eom.py index c2858a77..863ceb6f 100644 --- a/examples/hlapi/asyncore/sync/manager/cmdgen/getnext-multiple-oids-to-eom.py +++ b/examples/hlapi/asyncore/sync/manager/cmdgen/getnext-multiple-oids-to-eom.py @@ -12,31 +12,28 @@ Send a series of SNMP GETNEXT requests using the following options: Functionally similar to: -| $ snmpwalk -v2c -c public demo.snmplabs.com \ -| 1.3.6.1.2.1.2.2.1.2 1.3.6.1.2.1.2.2.1.3 +| $ snmpwalk -v2c -c public demo.snmplabs.com 1.3.6.1.2.1.2.2.1.2 1.3.6.1.2.1.2.2.1.3 """# from pysnmp.hlapi import * -for errorIndication, \ - errorStatus, errorIndex, \ - varBinds in nextCmd(SnmpEngine(), - CommunityData('public'), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ContextData(), - ObjectType(ObjectIdentity('1.3.6.1.2.1.2.2.1.2')), - ObjectType(ObjectIdentity('1.3.6.1.2.1.2.2.1.3')), - lexicographicMode=False): +for (errorIndication, + errorStatus, + errorIndex, + varBinds) in nextCmd(SnmpEngine(), + CommunityData('public'), + UdpTransportTarget(('demo.snmplabs.com', 161)), + ContextData(), + ObjectType(ObjectIdentity('1.3.6.1.2.1.2.2.1.2')), + ObjectType(ObjectIdentity('1.3.6.1.2.1.2.2.1.3')), + lexicographicMode=False): 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 '?')) break else: for varBind in varBinds: diff --git a/examples/hlapi/asyncore/sync/manager/cmdgen/multiple-get-calls.py b/examples/hlapi/asyncore/sync/manager/cmdgen/multiple-get-calls.py index d8c63ef1..c08b9f47 100644 --- a/examples/hlapi/asyncore/sync/manager/cmdgen/multiple-get-calls.py +++ b/examples/hlapi/asyncore/sync/manager/cmdgen/multiple-get-calls.py @@ -16,14 +16,13 @@ could consume input Functionally similar to: -| $ snmpget -v3 -l authNoPriv -u usr-md5-none -A authkey1 demo.snmplabs.com \ -| IF-MIB::ifInOctets.1 +| $ snmpget -v3 -l authNoPriv -u usr-md5-none -A authkey1 demo.snmplabs.com IF-MIB::ifInOctets.1 """# from pysnmp.hlapi import * -queue = [ [ ObjectType(ObjectIdentity('IF-MIB', 'ifInOctets', 1)) ], - [ ObjectType(ObjectIdentity('IF-MIB', 'ifOutOctets', 1)) ] ] +queue = [[ObjectType(ObjectIdentity('IF-MIB', 'ifInOctets', 1))], + [ObjectType(ObjectIdentity('IF-MIB', 'ifOutOctets', 1))]] iter = getCmd(SnmpEngine(), UsmUserData('usr-md5-none', 'authkey1'), @@ -37,11 +36,8 @@ while queue: 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])) diff --git a/examples/hlapi/asyncore/sync/manager/cmdgen/preload-pysnmp-mibs.py b/examples/hlapi/asyncore/sync/manager/cmdgen/preload-pysnmp-mibs.py index 885dbdfc..27186431 100644 --- a/examples/hlapi/asyncore/sync/manager/cmdgen/preload-pysnmp-mibs.py +++ b/examples/hlapi/asyncore/sync/manager/cmdgen/preload-pysnmp-mibs.py @@ -12,32 +12,27 @@ Send a series of SNMP GETNEXT requests using the following options: Functionally similar to: -| $ snmpwalk -v3 -l authPriv -u usr-md5-des -A authkey1 -X privkey1 \ -| -m ALL -| udp6:[::1]:161 \ -| 1.3.6 +| $ snmpwalk -v3 -l authPriv -u usr-md5-des -A authkey1 -X privkey1 -m ALL udp6:[::1]:161 1.3.6 """# from pysnmp.hlapi import * -for errorIndication, \ - errorStatus, errorIndex, \ - varBinds in nextCmd(SnmpEngine(), - UsmUserData('usr-md5-des', 'authkey1', 'privkey1'), - Udp6TransportTarget(('::1', 161)), - ContextData(), - ObjectType(ObjectIdentity('1.3.6').loadMibs())): +for (errorIndication, + errorStatus, + errorIndex, + varBinds) in nextCmd(SnmpEngine(), + UsmUserData('usr-md5-des', 'authkey1', 'privkey1'), + Udp6TransportTarget(('::1', 161)), + ContextData(), + ObjectType(ObjectIdentity('1.3.6').loadMibs())): 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 '?')) break else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) diff --git a/examples/hlapi/twisted/agent/ntforg/default-v1-trap.py b/examples/hlapi/twisted/agent/ntforg/default-v1-trap.py index ea99b52e..49eddb9b 100644 --- a/examples/hlapi/twisted/agent/ntforg/default-v1-trap.py +++ b/examples/hlapi/twisted/agent/ntforg/default-v1-trap.py @@ -38,6 +38,8 @@ def success((errorStatus, errorIndex, varBinds), hostname): def failure(errorIndication, hostname): print('%s failure: %s' % (hostname, errorIndication)) + +# noinspection PyUnusedLocal def run(reactor, hostname): d = sendNotification( SnmpEngine(), diff --git a/examples/hlapi/twisted/agent/ntforg/multiple-notifications-at-once.py b/examples/hlapi/twisted/agent/ntforg/multiple-notifications-at-once.py index e6ff1165..14b41091 100644 --- a/examples/hlapi/twisted/agent/ntforg/multiple-notifications-at-once.py +++ b/examples/hlapi/twisted/agent/ntforg/multiple-notifications-at-once.py @@ -41,6 +41,8 @@ def success((errorStatus, errorIndex, varBinds), hostname): def failure(errorIndication, hostname): print('%s failure: %s' % (hostname, errorIndication)) + +# noinspection PyUnusedLocal def sendone(reactor, snmpEngine, hostname, notifyType): d = sendNotification( snmpEngine, diff --git a/examples/hlapi/twisted/manager/cmdgen/custom-timeout-and-retries.py b/examples/hlapi/twisted/manager/cmdgen/custom-timeout-and-retries.py index fefcd68d..19dfadda 100644 --- a/examples/hlapi/twisted/manager/cmdgen/custom-timeout-and-retries.py +++ b/examples/hlapi/twisted/manager/cmdgen/custom-timeout-and-retries.py @@ -33,6 +33,8 @@ def success((errorStatus, errorIndex, varBinds), hostname): def failure(errorIndication, hostname): print('%s failure: %s' % (hostname, errorIndication)) + +# noinspection PyUnusedLocal def getSysDescr(reactor, hostname): snmpEngine = SnmpEngine() diff --git a/examples/hlapi/twisted/manager/cmdgen/multiple-concurrent-queries.py b/examples/hlapi/twisted/manager/cmdgen/multiple-concurrent-queries.py index 5349e973..86a616ba 100644 --- a/examples/hlapi/twisted/manager/cmdgen/multiple-concurrent-queries.py +++ b/examples/hlapi/twisted/manager/cmdgen/multiple-concurrent-queries.py @@ -36,6 +36,8 @@ def success((errorStatus, errorIndex, varBinds), hostname): def failure(errorIndication, hostname): print('%s failure: %s' % (hostname, errorIndication)) + +# noinspection PyUnusedLocal def getSystem(reactor, hostname): snmpEngine = SnmpEngine() diff --git a/examples/hlapi/twisted/manager/cmdgen/v1-get.py b/examples/hlapi/twisted/manager/cmdgen/v1-get.py index 02b36906..051c58a8 100644 --- a/examples/hlapi/twisted/manager/cmdgen/v1-get.py +++ b/examples/hlapi/twisted/manager/cmdgen/v1-get.py @@ -33,6 +33,8 @@ def success((errorStatus, errorIndex, varBinds), hostname): def failure(errorIndication, hostname): print('%s failure: %s' % (hostname, errorIndication)) + +# noinspection PyUnusedLocal def getSysDescr(reactor, hostname): d = getCmd(SnmpEngine(), CommunityData('public', mpModel=0), diff --git a/examples/smi/agent/custom-managed-object.py b/examples/smi/agent/custom-managed-object.py index a5abda7c..56fd15c8 100644 --- a/examples/smi/agent/custom-managed-object.py +++ b/examples/smi/agent/custom-managed-object.py @@ -19,6 +19,7 @@ sysLocation, = mibBuilder.importSymbols('SNMPv2-MIB', 'sysLocation') # Custom Managed Object class MySysLocationInstance(MibScalarInstance): + # noinspection PyUnusedLocal def readGet(self, name, *args): # Just return a custom value return name, self.syntax.clone('The Leaky Cauldron') diff --git a/examples/v1arch/asyncore/agent/ntforg/send-inform-over-ipv4-and-ipv6.py b/examples/v1arch/asyncore/agent/ntforg/send-inform-over-ipv4-and-ipv6.py index 7221355d..528d4fe0 100644 --- a/examples/v1arch/asyncore/agent/ntforg/send-inform-over-ipv4-and-ipv6.py +++ b/examples/v1arch/asyncore/agent/ntforg/send-inform-over-ipv4-and-ipv6.py @@ -39,6 +39,8 @@ def cbTimerFun(timeNow): if timeNow - startedAt > 3: raise Exception("Request timed out") + +# noinspection PyUnusedLocal,PyUnusedLocal def cbRecvFun(transportDispatcher, transportDomain, transportAddress, wholeMsg, reqPDU=reqPDU): while wholeMsg: diff --git a/examples/v1arch/asyncore/manager/cmdgen/broadcast-agent-discovery.py b/examples/v1arch/asyncore/manager/cmdgen/broadcast-agent-discovery.py index cd8c3c99..c2452282 100644 --- a/examples/v1arch/asyncore/manager/cmdgen/broadcast-agent-discovery.py +++ b/examples/v1arch/asyncore/manager/cmdgen/broadcast-agent-discovery.py @@ -55,7 +55,9 @@ class StopWaiting(Exception): pass def cbTimerFun(timeNow): if timeNow - startedAt > maxWaitForResponses: raise StopWaiting() - + + +# noinspection PyUnusedLocal,PyUnusedLocal def cbRecvFun(transportDispatcher, transportDomain, transportAddress, wholeMsg, reqPDU=reqPDU): while wholeMsg: diff --git a/examples/v1arch/asyncore/manager/cmdgen/fetch-scalar-value.py b/examples/v1arch/asyncore/manager/cmdgen/fetch-scalar-value.py index f4bb0cf4..c350f85b 100644 --- a/examples/v1arch/asyncore/manager/cmdgen/fetch-scalar-value.py +++ b/examples/v1arch/asyncore/manager/cmdgen/fetch-scalar-value.py @@ -43,7 +43,9 @@ startedAt = time() def cbTimerFun(timeNow): if timeNow - startedAt > 3: raise Exception("Request timed out") - + + +# noinspection PyUnusedLocal,PyUnusedLocal def cbRecvFun(transportDispatcher, transportDomain, transportAddress, wholeMsg, reqPDU=reqPDU): while wholeMsg: diff --git a/examples/v1arch/asyncore/manager/cmdgen/getbulk-pull-whole-mib.py b/examples/v1arch/asyncore/manager/cmdgen/getbulk-pull-whole-mib.py index 8ba9af62..c19194d5 100644 --- a/examples/v1arch/asyncore/manager/cmdgen/getbulk-pull-whole-mib.py +++ b/examples/v1arch/asyncore/manager/cmdgen/getbulk-pull-whole-mib.py @@ -43,6 +43,8 @@ def cbTimerFun(timeNow): if timeNow - startedAt > 3: raise Exception("Request timed out") + +# noinspection PyUnusedLocal def cbRecvFun(transportDispatcher, transportDomain, transportAddress, wholeMsg, reqPDU=reqPDU, headVars=headVars): while wholeMsg: diff --git a/examples/v1arch/asyncore/manager/cmdgen/getnext-pull-whole-mib.py b/examples/v1arch/asyncore/manager/cmdgen/getnext-pull-whole-mib.py index b3e16f19..9dfc52c3 100644 --- a/examples/v1arch/asyncore/manager/cmdgen/getnext-pull-whole-mib.py +++ b/examples/v1arch/asyncore/manager/cmdgen/getnext-pull-whole-mib.py @@ -44,6 +44,8 @@ def cbTimerFun(timeNow): if timeNow - startedAt > 3: raise Exception("Request timed out") + +# noinspection PyUnusedLocal def cbRecvFun(transportDispatcher, transportDomain, transportAddress, wholeMsg, reqPDU=reqPDU, headVars=headVars): while wholeMsg: diff --git a/examples/v1arch/asyncore/manager/cmdgen/spoof-source-address.py b/examples/v1arch/asyncore/manager/cmdgen/spoof-source-address.py index 16009ab8..332bb8d2 100644 --- a/examples/v1arch/asyncore/manager/cmdgen/spoof-source-address.py +++ b/examples/v1arch/asyncore/manager/cmdgen/spoof-source-address.py @@ -65,7 +65,9 @@ class StopWaiting(Exception): pass def cbTimerFun(timeNow): if timeNow - startedAt > 3: raise StopWaiting() - + + +# noinspection PyUnusedLocal,PyUnusedLocal def cbRecvFun(transportDispatcher, transportDomain, transportAddress, wholeMsg, reqPDU=reqPDU): while wholeMsg: diff --git a/examples/v1arch/asyncore/manager/cmdgen/v2c-set.py b/examples/v1arch/asyncore/manager/cmdgen/v2c-set.py index a30bebb6..5c8c8318 100644 --- a/examples/v1arch/asyncore/manager/cmdgen/v2c-set.py +++ b/examples/v1arch/asyncore/manager/cmdgen/v2c-set.py @@ -45,7 +45,9 @@ startedAt = time() def cbTimerFun(timeNow): if timeNow - startedAt > 3: raise Exception("Request timed out") - + + +# noinspection PyUnusedLocal,PyUnusedLocal def cbRecvFun(transportDispatcher, transportDomain, transportAddress, wholeMsg, reqPDU=reqPDU): while wholeMsg: diff --git a/examples/v1arch/asyncore/manager/ntfrcv/listen-on-ipv4-and-ipv6-interfaces.py b/examples/v1arch/asyncore/manager/ntfrcv/listen-on-ipv4-and-ipv6-interfaces.py index b9073cf2..0dd60faa 100644 --- a/examples/v1arch/asyncore/manager/ntfrcv/listen-on-ipv4-and-ipv6-interfaces.py +++ b/examples/v1arch/asyncore/manager/ntfrcv/listen-on-ipv4-and-ipv6-interfaces.py @@ -25,6 +25,8 @@ from pysnmp.carrier.asyncore.dgram import udp, udp6, unix from pyasn1.codec.ber import decoder from pysnmp.proto import api + +# noinspection PyUnusedLocal def cbFun(transportDispatcher, transportDomain, transportAddress, wholeMsg): while wholeMsg: msgVer = int(api.decodeMessageVersion(wholeMsg)) diff --git a/examples/v3arch/asyncio/manager/ntfrcv/multiple-interfaces.py b/examples/v3arch/asyncio/manager/ntfrcv/multiple-interfaces.py index 30dc5111..429b117d 100644 --- a/examples/v3arch/asyncio/manager/ntfrcv/multiple-interfaces.py +++ b/examples/v3arch/asyncio/manager/ntfrcv/multiple-interfaces.py @@ -54,6 +54,7 @@ config.addTransport( config.addV1System(snmpEngine, 'my-area', 'public') # Callback function for receiving notifications +# noinspection PyUnusedLocal def cbFun(snmpEngine, stateReference, contextEngineId, contextName, diff --git a/examples/v3arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects.py b/examples/v3arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects.py index 196ee9c2..24d76d35 100644 --- a/examples/v3arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects.py +++ b/examples/v3arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects.py @@ -54,6 +54,7 @@ MibScalar, MibScalarInstance = mibBuilder.importSymbols( ) class MyStaticMibScalarInstance(MibScalarInstance): + # noinspection PyUnusedLocal,PyUnusedLocal def getValue(self, name, idx): return self.getSyntax().clone( 'Python %s running on a %s platform' % (sys.version, sys.platform) diff --git a/examples/v3arch/asyncore/agent/cmdrsp/observe-request-processing.py b/examples/v3arch/asyncore/agent/cmdrsp/observe-request-processing.py index d03c52c1..06b5b563 100644 --- a/examples/v3arch/asyncore/agent/cmdrsp/observe-request-processing.py +++ b/examples/v3arch/asyncore/agent/cmdrsp/observe-request-processing.py @@ -31,6 +31,7 @@ snmpEngine = engine.SnmpEngine() # Register a callback to be invoked at specified execution point of # SNMP Engine and passed local variables at code point's local scope +# noinspection PyUnusedLocal,PyUnusedLocal def requestObserver(snmpEngine, execpoint, variables, cbCtx): print('Execution point: %s' % execpoint) print('* transportDomain: %s' % '.'.join([str(x) for x in variables['transportDomain']])) diff --git a/examples/v3arch/asyncore/agent/ntforg/multiple-different-notifications-at-once.py b/examples/v3arch/asyncore/agent/ntforg/multiple-different-notifications-at-once.py index 237b8e0e..e316e674 100644 --- a/examples/v3arch/asyncore/agent/ntforg/multiple-different-notifications-at-once.py +++ b/examples/v3arch/asyncore/agent/ntforg/multiple-different-notifications-at-once.py @@ -88,6 +88,7 @@ config.addVacmUser(snmpEngine, 3, 'usr-md5-none', 'authNoPriv', (), (), (1,3,6)) ntfOrg = ntforg.NotificationOriginator() # Error/confirmation receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): print('Notification %s, status - %s' % ( diff --git a/examples/v3arch/asyncore/agent/ntforg/send-custom-pdu.py b/examples/v3arch/asyncore/agent/ntforg/send-custom-pdu.py index 150b7dfc..5df87e80 100644 --- a/examples/v3arch/asyncore/agent/ntforg/send-custom-pdu.py +++ b/examples/v3arch/asyncore/agent/ntforg/send-custom-pdu.py @@ -67,6 +67,7 @@ v2c.apiTrapPDU.setVarBinds( ntfOrg = ntforg.NotificationOriginator() # Error/confirmation receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): print('Notification %s, status - %s' % ( diff --git a/examples/v3arch/asyncore/agent/ntforg/usm-md5-none.py b/examples/v3arch/asyncore/agent/ntforg/usm-md5-none.py index 66d0a040..904aafe0 100644 --- a/examples/v3arch/asyncore/agent/ntforg/usm-md5-none.py +++ b/examples/v3arch/asyncore/agent/ntforg/usm-md5-none.py @@ -64,6 +64,7 @@ config.addVacmUser(snmpEngine, 3, 'usr-md5-none', 'authNoPriv', (), (), (1,3,6)) ntfOrg = ntforg.NotificationOriginator() # Error/confirmation receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): print('Notification %s, status - %s' % ( diff --git a/examples/v3arch/asyncore/agent/ntforg/v2c-inform.py b/examples/v3arch/asyncore/agent/ntforg/v2c-inform.py index 4e02f71b..8c3c90b4 100644 --- a/examples/v3arch/asyncore/agent/ntforg/v2c-inform.py +++ b/examples/v3arch/asyncore/agent/ntforg/v2c-inform.py @@ -66,6 +66,7 @@ config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1,3,6)) ntfOrg = ntforg.NotificationOriginator() # Error/confirmation receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): print('Notification %s, status - %s' % ( diff --git a/examples/v3arch/asyncore/agent/ntforg/v2c-trap.py b/examples/v3arch/asyncore/agent/ntforg/v2c-trap.py index 91fcaf7f..b2ecfa9b 100644 --- a/examples/v3arch/asyncore/agent/ntforg/v2c-trap.py +++ b/examples/v3arch/asyncore/agent/ntforg/v2c-trap.py @@ -65,6 +65,7 @@ config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1,3,6)) ntfOrg = ntforg.NotificationOriginator() # Error/confirmation receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): print('Notification %s, status - %s' % ( 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 e61e5389..eb1900c2 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/custom-contextengineid-and-contextname.py +++ b/examples/v3arch/asyncore/manager/cmdgen/custom-contextengineid-and-contextname.py @@ -54,6 +54,7 @@ config.addTargetAddr( ) # Error/response receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): if errorIndication: 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 b91a4b63..1e49ffef 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/custom-timeout-and-retries.py +++ b/examples/v3arch/asyncore/manager/cmdgen/custom-timeout-and-retries.py @@ -52,6 +52,7 @@ config.addTargetAddr( ) # Error/response receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): if errorIndication: 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 1856d80e..916537da 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/fetch-variables-over-ipv6.py +++ b/examples/v3arch/asyncore/manager/cmdgen/fetch-variables-over-ipv6.py @@ -51,6 +51,7 @@ config.addTargetAddr( ) # Error/response receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBindTable, cbCtx): if errorIndication: 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 8bd04a5c..516951f8 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 @@ -53,6 +53,7 @@ config.addTargetAddr( ) # Error/response receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequesthandle, errorIndication, errorStatus, errorIndex, varBindTable, cbCtx): if errorIndication: 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 9f5db70c..2cd37cda 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 @@ -50,6 +50,7 @@ config.addTargetAddr( ) # Error/response receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequesthandle, errorIndication, errorStatus, errorIndex, varBindTable, cbCtx): if errorIndication: 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 d69abfeb..f4667bef 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 @@ -61,6 +61,7 @@ config.addTargetAddr( ) # Error/response receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBindTable, cbCtx): if errorIndication: 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 0a41a416..f2bcc43e 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 @@ -50,6 +50,7 @@ config.addTargetAddr( ) # Error/response receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBindTable, cbCtx): if errorIndication: diff --git a/examples/v3arch/asyncore/manager/cmdgen/observe-request-processing.py b/examples/v3arch/asyncore/manager/cmdgen/observe-request-processing.py index 0914ac36..86187923 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/observe-request-processing.py +++ b/examples/v3arch/asyncore/manager/cmdgen/observe-request-processing.py @@ -29,6 +29,7 @@ snmpEngine = engine.SnmpEngine() # Register a callback to be invoked at specified execution point of # SNMP Engine and passed local variables at code point's local scope +# noinspection PyUnusedLocal,PyUnusedLocal def requestObserver(snmpEngine, execpoint, variables, cbCtx): print('Execution point: %s' % execpoint) print('* transportDomain: %s' % '.'.join([str(x) for x in variables['transportDomain']])) @@ -76,6 +77,7 @@ config.addTargetAddr( ) # Error/response receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): if errorIndication: diff --git a/examples/v3arch/asyncore/manager/cmdgen/pull-subtree.py b/examples/v3arch/asyncore/manager/cmdgen/pull-subtree.py index 5edc744e..36e461fb 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/pull-subtree.py +++ b/examples/v3arch/asyncore/manager/cmdgen/pull-subtree.py @@ -53,6 +53,7 @@ config.addTargetAddr( ) # Error/response receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBindTable, cbCtx): if errorIndication: 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 022742a7..27acf769 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 @@ -51,6 +51,7 @@ config.addTargetAddr( ) # Error/response receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBindTable, cbCtx): if errorIndication: 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 55a87202..28095a76 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/set-multiple-scalar-values.py +++ b/examples/v3arch/asyncore/manager/cmdgen/set-multiple-scalar-values.py @@ -50,6 +50,7 @@ config.addTargetAddr( ) # Error/response receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): if errorIndication: diff --git a/examples/v3arch/asyncore/manager/cmdgen/spoof-source-address.py b/examples/v3arch/asyncore/manager/cmdgen/spoof-source-address.py index 998d40f4..953f80e6 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/spoof-source-address.py +++ b/examples/v3arch/asyncore/manager/cmdgen/spoof-source-address.py @@ -71,6 +71,7 @@ config.addTargetAddr( ) # Error/response receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): if errorIndication: diff --git a/examples/v3arch/asyncore/manager/cmdgen/usm-sha-aes128.py b/examples/v3arch/asyncore/manager/cmdgen/usm-sha-aes128.py index f7ff4ee5..58154ba1 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/usm-sha-aes128.py +++ b/examples/v3arch/asyncore/manager/cmdgen/usm-sha-aes128.py @@ -50,6 +50,7 @@ config.addTargetAddr( ) # Error/response receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): if errorIndication: diff --git a/examples/v3arch/asyncore/manager/cmdgen/usm-sha-none.py b/examples/v3arch/asyncore/manager/cmdgen/usm-sha-none.py index 1c39d33d..45692e4c 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/usm-sha-none.py +++ b/examples/v3arch/asyncore/manager/cmdgen/usm-sha-none.py @@ -51,6 +51,7 @@ config.addTargetAddr( ) # Error/response receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): if errorIndication: diff --git a/examples/v3arch/asyncore/manager/cmdgen/v1-get.py b/examples/v3arch/asyncore/manager/cmdgen/v1-get.py index 234d414f..9e9019cd 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/v1-get.py +++ b/examples/v3arch/asyncore/manager/cmdgen/v1-get.py @@ -47,6 +47,7 @@ config.addTargetAddr( ) # Error/response receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): if errorIndication: diff --git a/examples/v3arch/asyncore/manager/cmdgen/v2c-set.py b/examples/v3arch/asyncore/manager/cmdgen/v2c-set.py index 9f7068fb..7936f174 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/v2c-set.py +++ b/examples/v3arch/asyncore/manager/cmdgen/v2c-set.py @@ -49,6 +49,7 @@ config.addTargetAddr( ) # Error/response receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): if errorIndication: diff --git a/examples/v3arch/asyncore/manager/ntfrcv/determine-peer-network-address.py b/examples/v3arch/asyncore/manager/ntfrcv/determine-peer-network-address.py index d8619def..87880e41 100644 --- a/examples/v3arch/asyncore/manager/ntfrcv/determine-peer-network-address.py +++ b/examples/v3arch/asyncore/manager/ntfrcv/determine-peer-network-address.py @@ -39,6 +39,7 @@ config.addTransport( config.addV1System(snmpEngine, 'my-area', 'public') # Callback function for receiving notifications +# noinspection PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, stateReference, contextEngineId, contextName, varBinds, cbCtx): # Get an execution context... diff --git a/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-interfaces.py b/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-interfaces.py index 402f9308..63c86926 100644 --- a/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-interfaces.py +++ b/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-interfaces.py @@ -47,6 +47,7 @@ config.addTransport( config.addV1System(snmpEngine, 'my-area', 'public') # Callback function for receiving notifications +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, stateReference, contextEngineId, contextName, varBinds, cbCtx): print('Notification from ContextEngineId "%s", ContextName "%s"' % ( diff --git a/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-transports.py b/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-transports.py index 31fcb2b5..c0e2eeae 100644 --- a/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-transports.py +++ b/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-transports.py @@ -48,6 +48,7 @@ config.addTransport( config.addV1System(snmpEngine, 'my-area', 'public') # Callback function for receiving notifications +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, stateReference, contextEngineId, contextName, varBinds, cbCtx): print('Notification from ContextEngineId "%s", ContextName "%s"' % ( diff --git a/examples/v3arch/asyncore/manager/ntfrcv/multiple-usm-users.py b/examples/v3arch/asyncore/manager/ntfrcv/multiple-usm-users.py index 037062b9..1a0ae8bd 100644 --- a/examples/v3arch/asyncore/manager/ntfrcv/multiple-usm-users.py +++ b/examples/v3arch/asyncore/manager/ntfrcv/multiple-usm-users.py @@ -88,6 +88,7 @@ config.addV3User( ) # Callback function for receiving notifications +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, stateReference, contextEngineId, contextName, varBinds, cbCtx): print('Notification from ContextEngineId "%s", ContextName "%s"' % ( diff --git a/examples/v3arch/asyncore/manager/ntfrcv/observe-request-processing.py b/examples/v3arch/asyncore/manager/ntfrcv/observe-request-processing.py index ed44146c..6dd9b305 100644 --- a/examples/v3arch/asyncore/manager/ntfrcv/observe-request-processing.py +++ b/examples/v3arch/asyncore/manager/ntfrcv/observe-request-processing.py @@ -31,6 +31,7 @@ snmpEngine = engine.SnmpEngine() # Register a callback to be invoked at specified execution point of # SNMP Engine and passed local variables at code point's local scope +# noinspection PyUnusedLocal,PyUnusedLocal def requestObserver(snmpEngine, execpoint, variables, cbCtx): print('Execution point: %s' % execpoint) print('* transportDomain: %s' % '.'.join([str(x) for x in variables['transportDomain']])) @@ -70,6 +71,7 @@ config.addTransport( config.addV1System(snmpEngine, 'my-area', 'public') # Callback function for receiving notifications +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, stateReference, contextEngineId, contextName, varBinds, cbCtx): print('Notification from ContextEngineId "%s", ContextName "%s"' % ( diff --git a/examples/v3arch/asyncore/manager/ntfrcv/regexp-community-name.py b/examples/v3arch/asyncore/manager/ntfrcv/regexp-community-name.py index 759bf980..0e808ec9 100644 --- a/examples/v3arch/asyncore/manager/ntfrcv/regexp-community-name.py +++ b/examples/v3arch/asyncore/manager/ntfrcv/regexp-community-name.py @@ -40,6 +40,7 @@ snmpEngine = engine.SnmpEngine() # If at this execution point passed variables are modified, their new # values will be propagated back and used by SNMP Engine for securityName # selection. +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def requestObserver(snmpEngine, execpoint, variables, cbCtx): if re.match('.*love.*', str(variables['communityName'])): print('Rewriting communityName \'%s\' from %s into \'public\'' % (variables['communityName'], ':'.join([str(x) for x in variables['transportInformation'][1]]))) @@ -65,6 +66,7 @@ config.addTransport( config.addV1System(snmpEngine, 'my-area', 'public') # Callback function for receiving notifications +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, stateReference, contextEngineId, contextName, varBinds, cbCtx): print('Notification from ContextEngineId "%s", ContextName "%s"' % ( diff --git a/examples/v3arch/asyncore/proxy/command/udp6-to-udp4-conversion.py b/examples/v3arch/asyncore/proxy/command/udp6-to-udp4-conversion.py index a13df6b6..d06261a3 100644 --- a/examples/v3arch/asyncore/proxy/command/udp6-to-udp4-conversion.py +++ b/examples/v3arch/asyncore/proxy/command/udp6-to-udp4-conversion.py @@ -116,6 +116,7 @@ class CommandResponder(cmdrsp.CommandResponderBase): ) # SNMP response relay + # noinspection PyUnusedLocal def handleResponsePdu(self, snmpEngine, sendRequestHandle, errorIndication, PDU, cbCtx): stateReference, reqPDU = cbCtx diff --git a/examples/v3arch/asyncore/proxy/command/v2c-to-v1-conversion.py b/examples/v3arch/asyncore/proxy/command/v2c-to-v1-conversion.py index 4e78dfca..c8dc63eb 100644 --- a/examples/v3arch/asyncore/proxy/command/v2c-to-v1-conversion.py +++ b/examples/v3arch/asyncore/proxy/command/v2c-to-v1-conversion.py @@ -114,6 +114,7 @@ class CommandResponder(cmdrsp.CommandResponderBase): ) # SNMP response relay + # noinspection PyUnusedLocal def handleResponsePdu(self, snmpEngine, sendRequestHandle, errorIndication, PDU, cbCtx): stateReference, reqPDU = cbCtx diff --git a/examples/v3arch/asyncore/proxy/command/v2c-to-v3-conversion.py b/examples/v3arch/asyncore/proxy/command/v2c-to-v3-conversion.py index ca269f73..e232e19e 100644 --- a/examples/v3arch/asyncore/proxy/command/v2c-to-v3-conversion.py +++ b/examples/v3arch/asyncore/proxy/command/v2c-to-v3-conversion.py @@ -114,6 +114,7 @@ class CommandResponder(cmdrsp.CommandResponderBase): ) # SNMP response relay + # noinspection PyUnusedLocal def handleResponsePdu(self, snmpEngine, sendRequestHandle, errorIndication, PDU, cbCtx): stateReference, reqPDU = cbCtx diff --git a/examples/v3arch/asyncore/proxy/command/v3-to-v2c-conversion.py b/examples/v3arch/asyncore/proxy/command/v3-to-v2c-conversion.py index da9aba3e..8247e45e 100644 --- a/examples/v3arch/asyncore/proxy/command/v3-to-v2c-conversion.py +++ b/examples/v3arch/asyncore/proxy/command/v3-to-v2c-conversion.py @@ -117,6 +117,7 @@ class CommandResponder(cmdrsp.CommandResponderBase): ) # SNMP response relay + # noinspection PyUnusedLocal def handleResponsePdu(self, snmpEngine, sendRequestHandle, errorIndication, PDU, cbCtx): stateReference, reqPDU = cbCtx diff --git a/examples/v3arch/twisted/agent/cmdrsp/implementing-scalar-mib-objects.py b/examples/v3arch/twisted/agent/cmdrsp/implementing-scalar-mib-objects.py index 565419d4..80a2411b 100644 --- a/examples/v3arch/twisted/agent/cmdrsp/implementing-scalar-mib-objects.py +++ b/examples/v3arch/twisted/agent/cmdrsp/implementing-scalar-mib-objects.py @@ -57,6 +57,7 @@ MibScalar, MibScalarInstance = mibBuilder.importSymbols( ) class MyStaticMibScalarInstance(MibScalarInstance): + # noinspection PyUnusedLocal,PyUnusedLocal def getValue(self, name, idx): return self.getSyntax().clone( 'Python %s running on a %s platform' % (sys.version, sys.platform) diff --git a/examples/v3arch/twisted/manager/ntfrcv/multiple-interfaces.py b/examples/v3arch/twisted/manager/ntfrcv/multiple-interfaces.py index b7edf7dd..33066091 100644 --- a/examples/v3arch/twisted/manager/ntfrcv/multiple-interfaces.py +++ b/examples/v3arch/twisted/manager/ntfrcv/multiple-interfaces.py @@ -50,6 +50,7 @@ config.addTransport( config.addV1System(snmpEngine, 'my-area', 'public') # Callback function for receiving notifications +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, stateReference, contextEngineId, contextName, varBinds, cbCtx): print('Notification from ContextEngineId "%s", Context "%s"' % ( diff --git a/examples/v3arch/twisted/manager/ntfrcv/multiple-usm-users.py b/examples/v3arch/twisted/manager/ntfrcv/multiple-usm-users.py index a82bd3dd..a9f7e45a 100644 --- a/examples/v3arch/twisted/manager/ntfrcv/multiple-usm-users.py +++ b/examples/v3arch/twisted/manager/ntfrcv/multiple-usm-users.py @@ -91,6 +91,7 @@ config.addV3User( # -- end of SNMPv3/USM setup # Callback function for receiving notifications +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, stateReference, contextEngineId, contextName, varBinds, cbCtx): print('Notification from ContextEngineId "%s", ContextName "%s"' % ( |