From c770b66faac4527396f13ef3bd28ce7b187d8fe5 Mon Sep 17 00:00:00 2001 From: elie Date: Sun, 14 Nov 2010 08:30:18 +0000 Subject: fix to use errorIndex only when it is set (to non-zero) --- examples/v3arch/manager/setgen.py | 9 ++++++--- examples/v3arch/oneliner/manager/bulkgen.py | 2 +- examples/v3arch/oneliner/manager/getgen.py | 3 ++- examples/v3arch/oneliner/manager/nextgen.py | 2 +- examples/v3arch/oneliner/manager/setgen.py | 3 ++- 5 files changed, 12 insertions(+), 7 deletions(-) (limited to 'examples') diff --git a/examples/v3arch/manager/setgen.py b/examples/v3arch/manager/setgen.py index 0681025..4b90f31 100644 --- a/examples/v3arch/manager/setgen.py +++ b/examples/v3arch/manager/setgen.py @@ -51,10 +51,13 @@ snmpEngine.transportDispatcher.runDispatcher() if cbCtx['errorIndication']: print cbCtx['errorIndication'] elif cbCtx['errorStatus']: - print '%s at %s' % ( - cbCtx['errorStatus'].prettyPrint(), - cbCtx['varBinds'][int(cbCtx['errorIndex'])-1] + if cbCtx['errorIndex']: + print '%s at %s' % ( + cbCtx['errorStatus'].prettyPrint(), + cbCtx['varBinds'][int(cbCtx['errorIndex'])-1] ) + else: + print cbCtx['errorStatus'].prettyPrint() else: for o, v in cbCtx['varBinds']: print '%s = %s' % (o.prettyPrint(), v.prettyPrint()) diff --git a/examples/v3arch/oneliner/manager/bulkgen.py b/examples/v3arch/oneliner/manager/bulkgen.py index db6c654..98646a1 100644 --- a/examples/v3arch/oneliner/manager/bulkgen.py +++ b/examples/v3arch/oneliner/manager/bulkgen.py @@ -20,7 +20,7 @@ else: if errorStatus: print '%s at %s\n' % ( errorStatus.prettyPrint(), - varBindTable[-1][int(errorIndex)-1] + errorIndex and varBindTable[-1][int(errorIndex)-1] or '?' ) else: for varBindTableRow in varBindTable: diff --git a/examples/v3arch/oneliner/manager/getgen.py b/examples/v3arch/oneliner/manager/getgen.py index 3b7fce8..80f52c9 100644 --- a/examples/v3arch/oneliner/manager/getgen.py +++ b/examples/v3arch/oneliner/manager/getgen.py @@ -21,7 +21,8 @@ if errorIndication: else: if errorStatus: print '%s at %s\n' % ( - errorStatus.prettyPrint(), varBinds[int(errorIndex)-1] + errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex)-1] or '?' ) else: for name, val in varBinds: diff --git a/examples/v3arch/oneliner/manager/nextgen.py b/examples/v3arch/oneliner/manager/nextgen.py index defbfe4..a5ad517 100644 --- a/examples/v3arch/oneliner/manager/nextgen.py +++ b/examples/v3arch/oneliner/manager/nextgen.py @@ -19,7 +19,7 @@ else: if errorStatus: print '%s at %s\n' % ( errorStatus.prettyPrint(), - varBindTable[-1][int(errorIndex)-1] + errorIndex and varBindTable[-1][int(errorIndex)-1] or '?' ) else: for varBindTableRow in varBindTable: diff --git a/examples/v3arch/oneliner/manager/setgen.py b/examples/v3arch/oneliner/manager/setgen.py index 0eabdd3..30e13fb 100644 --- a/examples/v3arch/oneliner/manager/setgen.py +++ b/examples/v3arch/oneliner/manager/setgen.py @@ -22,7 +22,8 @@ if errorIndication: else: if errorStatus: print '%s at %s\n' % ( - errorStatus.prettyPrint(), varBinds[int(errorIndex)-1] + errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex)-1] or '?' ) else: for name, val in varBinds: -- cgit v1.2.1