Re: [pysnmp-users] UnboundLocalError: local variable 'errorIndication' referenced before assignment
Brought to you by:
elie
From: Patrick O. <pa...@og...> - 2015-10-28 21:47:32
|
Thanks! Do you have any estimate as to when 4.3.1 will be on pypi and able to be installed by pip? > On 28 okt. 2015, at 21:37, Ilya Etingof <il...@gl...> wrote: > > Hi Patrick, > > That issue has been fixed in 4.3.1. Please try it out and let me know in case of further issues: > > tarball download > >> On 28 Oct 2015, at 20:34, Patrick Ogenstad <pa...@og...> wrote: >> >> Hello, >> >> I ran into a problem after upgrading to pysnmp 4.3.0. >> >> Just running snmpwalk it looks like this: >> >> $ snmpwalk -v2c -c public 172.29.50.5 1.3.6.1.4.1.9.9.46.1.4.2 >> SNMPv2-SMI::enterprises.9.9.46.1.4.2 = No Such Object available on this agent at this OID >> >> The problem seems to be when you run a nextCmd against an object which currently doesn't exist. >> >> The code below works with pysnmp 4.2.5 >> >> from pysnmp.entity.rfc3413.oneliner import cmdgen >> cmdGen = cmdgen.CommandGenerator() >> >> errorIndication, errorStatus, errorIndex, varBindTable = cmdGen.nextCmd( >> cmdgen.CommunityData('public'), >> cmdgen.UdpTransportTarget(('172.29.50.5', 161)), >> '1.3.6.1.4.1.9.9.46.1.4.2', >> lookupMib=False, >> ) >> >> if errorIndication: >> print(errorIndication) >> else: >> if errorStatus: >> print('%s at %s' % ( >> errorStatus.prettyPrint(), >> errorIndex and varBindTable[-1][int(errorIndex)-1] or '?' >> ) >> ) >> else: >> for varBindTableRow in varBindTable: >> for name, val in varBindTableRow: >> print('%s = %s' % (name.prettyPrint(), val.prettyPrint())) >> >> As the object doesn't exist on the device nothing is printed out. However running the same code with 4.3.0 gives this error: >> >> Traceback (most recent call last): >> File "<stdin>", line 5, in <module> >> File "/Users/patrick/.virtualenvs/prod/lib/python2.7/site-packages/pysnmp/entity/rfc3413/oneliner/cmdgen.py", line 222, in nextCmd >> return errorIndication, errorStatus, errorIndex, varBindTable >> UnboundLocalError: local variable 'errorIndication' referenced before assignment >> >> Is this something which can be solved in an easy way? >> >> Best regards >> Patrick |