summaryrefslogtreecommitdiff
path: root/examples/v1arch/asyncore/manager/cmdgen/broadcast-agent-discovery.py
diff options
context:
space:
mode:
authorIlya Etingof <etingof@gmail.com>2019-02-12 09:16:17 +0100
committerGitHub <noreply@github.com>2019-02-12 09:16:17 +0100
commitb9a7b9c955df98b1e5eec250f418c3df3b7d0199 (patch)
tree3364eb15031352859586e8eb6aa49759a23f9c72 /examples/v1arch/asyncore/manager/cmdgen/broadcast-agent-discovery.py
parentc5f7842c430ad3431bee793362ef11cff9f1e0de (diff)
downloadpysnmp-git-b9a7b9c955df98b1e5eec250f418c3df3b7d0199.tar.gz
Reformat example scripts for easier reading (#241)
Diffstat (limited to 'examples/v1arch/asyncore/manager/cmdgen/broadcast-agent-discovery.py')
-rw-r--r--examples/v1arch/asyncore/manager/cmdgen/broadcast-agent-discovery.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/examples/v1arch/asyncore/manager/cmdgen/broadcast-agent-discovery.py b/examples/v1arch/asyncore/manager/cmdgen/broadcast-agent-discovery.py
index 40eb0698..2fe5db4b 100644
--- a/examples/v1arch/asyncore/manager/cmdgen/broadcast-agent-discovery.py
+++ b/examples/v1arch/asyncore/manager/cmdgen/broadcast-agent-discovery.py
@@ -62,19 +62,25 @@ def cbTimerFun(timeNow):
# noinspection PyUnusedLocal,PyUnusedLocal
def cbRecvFun(transportDispatcher, transportDomain, transportAddress,
wholeMsg, reqPDU=reqPDU):
+
while wholeMsg:
rspMsg, wholeMsg = decoder.decode(wholeMsg, asn1Spec=pMod.Message())
rspPDU = pMod.apiMessage.getPDU(rspMsg)
+
# Match response to request
if pMod.apiPDU.getRequestID(reqPDU) == pMod.apiPDU.getRequestID(rspPDU):
+
# Check for SNMP errors reported
errorStatus = pMod.apiPDU.getErrorStatus(rspPDU)
if errorStatus:
print(errorStatus.prettyPrint())
+
else:
for oid, val in pMod.apiPDU.getVarBinds(rspPDU):
print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
+
transportDispatcher.jobFinished(1)
+
return wholeMsg
@@ -98,7 +104,6 @@ transportDispatcher.jobStarted(1, maxNumberResponses)
# Dispatcher will finish as all jobs counter reaches zero
try:
transportDispatcher.runDispatcher()
-except StopWaiting:
+
+finally:
transportDispatcher.closeDispatcher()
-else:
- raise