diff options
Diffstat (limited to 'pysnmp/hlapi/asyncore/_sync/compat/ntforg.py')
-rw-r--r-- | pysnmp/hlapi/asyncore/_sync/compat/ntforg.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/pysnmp/hlapi/asyncore/_sync/compat/ntforg.py b/pysnmp/hlapi/asyncore/_sync/compat/ntforg.py new file mode 100644 index 0000000..420b3b6 --- /dev/null +++ b/pysnmp/hlapi/asyncore/_sync/compat/ntforg.py @@ -0,0 +1,52 @@ +# +# This is a Python 2.6- version of the same file at level up +# +from pysnmp.hlapi.asyncore.ntforg import * + +__all__ = ['sendNotification', 'next'] + +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 |