Re: [pysnmp-users] Examples
Brought to you by:
elie
From: Ilya E. <il...@gl...> - 2003-09-20 06:33:04
|
There seems to be a bug in the compat code. It might be fixed by the attached patch. Please, let me know otherwise. The fix would be committed to revision 3.3.6. BTW, the compat code it intended mostly to support existing codebase, for new projects I'd suggest using native 3.x API. -ilya > I just downloaded pysnmp 3.3.5, and tried to run the following code > lifted from the example on the index page of the 2.x programmer's manual > shipped in the tar file. I had to modify it slightly to add the > qualifications to the module locations for the imports. > > ----- > > from pysnmp.compat.pysnmp2x import v2c, role, asn1 > req = v2c.GETREQUEST() > req['encoded_oids'] = [ asn1.OBJECTID().encode('1.3.6.1.2.1.1.1.0') ] > tr = role.manager(('10.1.1.10', 161)) > (rawrsp, src) = tr.send_and_receive(req.encode()) > rsp = v2c.RESPONSE() > rsp.decode(rawrsp) > oids = map(lambda x:x[0], map(asn1.OBJECTID().decode, rsp['encoded_oids'])) > vals = map(lambda x: x[0](), map(asn1.decode, rsp['encoded_vals'])) > print oids > print vals > > ----- > > When I run it, I get the following: > > ----- > > Traceback (most recent call last): > File "/home/dave/tsnmp.py", line 3, in ? > req['encoded_oids'] = [ asn1.OBJECTID().encode('1.3.6.1.2.1.1.1.0') ] > File "/usr/lib/python2.2/site-packages/pysnmp/compat/pysnmp2x/v1.py", line 250, in __setitem__ > return self._wrapper_fun(self._setitem_fun, key, value) > File "/usr/lib/python2.2/site-packages/pysnmp/compat/pysnmp2x/v2c.py", line 38, in _wrapper_fun > return apply(v1.CompatBase._wrapper_fun, [self, fun ] + list(args)) > File "/usr/lib/python2.2/site-packages/pysnmp/compat/pysnmp2x/v1.py", line 96, in _wrapper_fun > raise asn1.BadArgument(why) > pysnmp.compat.pysnmp2x.asn1.BadArgument: Non-ASN1 object [VarBind(name=ObjectName('.1.3.6.1.2.1.1.1.0'), value=BindValue(unspecified=Null(None)))] at VarBindList > > ----- > > I'm running python 2.2.2 on a Redhat 9 distro. Can anyone help me out? > > Thanks, > Dave |