Skip to content
Snippets Groups Projects
Commit 4ceae654 authored by Erik Reid's avatar Erik Reid
Browse files

Finished feature handle-propagated-errors-in-task-result.

parents 88448fd3 d85894fd
No related branches found
No related tags found
No related merge requests found
...@@ -57,9 +57,19 @@ def walk(agent_hostname, community, base_oid): # pragma: no cover ...@@ -57,9 +57,19 @@ def walk(agent_hostname, community, base_oid): # pragma: no cover
lexicographicMode=False, lexicographicMode=False,
lookupNames=True, lookupNames=True,
lookupValues=True): lookupValues=True):
assert not engineErrorIndication
assert not pduErrorIndication # cf. http://snmplabs.com/
assert errorIndex == 0 # pysnmp/examples/hlapi/asyncore/sync/contents.html
assert not engineErrorIndication, (
'snmp response engine error indication: %r'
% str(engineErrorIndication))
assert not pduErrorIndication, 'snmp response pdu error %r at %r' % (
pduErrorIndication,
errorIndex and varBinds[int(errorIndex) - 1][0] or '?')
assert errorIndex == 0, (
'sanity failure: errorIndex != 0, '
'but no error indication')
# varBinds = [ # varBinds = [
# rfc1902.ObjectType(rfc1902.ObjectIdentity(x[0]),x[1]) # rfc1902.ObjectType(rfc1902.ObjectIdentity(x[0]),x[1])
# .resolveWithMib(mibViewController) # .resolveWithMib(mibViewController)
......
...@@ -416,5 +416,13 @@ def check_task_status(task_id): ...@@ -416,5 +416,13 @@ def check_task_status(task_id):
'success': r.status == states.SUCCESS, 'success': r.status == states.SUCCESS,
} }
if r.result: if r.result:
result['result'] = r.result # TODO: only discovered this case by testing, is this the only one?
# ... otherwise need to pre-test json serialization
if isinstance(r.result, Exception):
result['result'] = {
'error type': type(r.result).__name__,
'message': str(r.result)
}
else:
result['result'] = r.result
return result return result
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment