diff options
author | elie <elie> | 2015-09-14 05:20:24 +0000 |
---|---|---|
committer | elie <elie> | 2015-09-14 05:20:24 +0000 |
commit | 2f24177c361ba4d9deba2d7378f84aa96111db80 (patch) | |
tree | 383c282bfe661bef3eaf16077946124c0039d9ab /pysnmp/entity/rfc3413/oneliner/sync/compat/ntforg.py | |
parent | 4397ac4bd10b626aa9355cf04ee0cdb410fe6030 (diff) | |
download | pysnmp-2f24177c361ba4d9deba2d7378f84aa96111db80.tar.gz |
* synchronous oneliner apps redesigned to offer Python generator-based
API along with a more comprehensive set of accepted parameters.
* massively documented (in Sphinx, NumPy style)
Diffstat (limited to 'pysnmp/entity/rfc3413/oneliner/sync/compat/ntforg.py')
-rw-r--r-- | pysnmp/entity/rfc3413/oneliner/sync/compat/ntforg.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/pysnmp/entity/rfc3413/oneliner/sync/compat/ntforg.py b/pysnmp/entity/rfc3413/oneliner/sync/compat/ntforg.py new file mode 100644 index 0000000..7a9291c --- /dev/null +++ b/pysnmp/entity/rfc3413/oneliner/sync/compat/ntforg.py @@ -0,0 +1,48 @@ +from pysnmp.entity.rfc3413.oneliner.ntforg import * + +if version_info[:2] < (2, 6): + def next(iter): + return iter.next() + +# +# Synchronous one-liner SNMP Notification Originator application +# + +def sendNotification(snmpEngine, authData, transportTarget, contextData, + notifyType, varBinds, **options): + + def cbFun(snmpEngine, sendRequestHandle, + errorIndication, errorStatus, errorIndex, + varBinds, cbCtx): + cbCtx['errorIndication'] = errorIndication + cbCtx['errorStatus'] = errorStatus + cbCtx['errorIndex'] = errorIndex + cbCtx['varBinds'] = varBinds + + cbCtx = {} + + ntfOrg = AsyncNotificationOriginator() + + if varBinds: + ntfOrg.sendNotification( + snmpEngine, + authData, + transportTarget, + contextData, + notifyType, + varBinds, + (cbFun, cbCtx), + options.get('lookupMib', True) + ) + + snmpEngine.transportDispatcher.runDispatcher() + + errorIndication = cbCtx.get('errorIndication') + errorStatus = cbCtx.get('errorStatus') + errorIndex = cbCtx.get('errorIndex') + varBinds = cbCtx.get('varBinds', []) + else: + errorIndication = errorStatus = errorIndex = None + varBinds = [] + + yield errorIndication, errorStatus, errorIndex, varBinds |