Re: [pysnmp-users] UnboundLocalError: local variable 'errorIndication' referenced before assignment
Brought to you by:
elie
From: Ilya E. <il...@gl...> - 2015-11-13 20:36:32
|
Hi Patrick, I’ve finally pushed pysnmp 4.3.1 to PyPI. Please, re-test and let me know if any issues remain unaddressed. Another change is a high-level py/SNMP tutorial that is shipped with pysnmp sources and is also available online: http://pysnmp.sourceforge.net/docs/tutorial.html > On 28 okt. 2015, at 22:25, Ilya Etingof <il...@gl... <mailto:il...@gl...>> wrote: > >> I’m looking to push it up there by the coming weekend, but not quite sure I get enough time for regression. I’ll send a note to this list as it’s done. >> >>> On 28 Oct 2015, at 22:19, Patrick Ogenstad <pa...@og... <mailto:pa...@og...>> wrote: >>> >>> 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... <mailto: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 <http://pysnmp.cvs.sourceforge.net/viewvc/pysnmp/pysnmp/?view=tar> >>>>> On 28 Oct 2015, at 20:34, Patrick Ogenstad <pa...@og... <mailto: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 >> |