Google

LINK="#0000bb" VLINK="#551a8b" ALINK="#ff0000">

Example of GetResponse object usage

>>> from pysnmp.proto import v1
>>> rsp = v1.GetResponse()
>>> rsp
"GetResponse(version=Version(0), community=Community('public'), pdu=Pdus(get_response=GetResponsePdu(request_id=RequestId(1L), error_status=ErrorStatus(0), error_index=ErrorIndex(0), variable_bindings=VarBindList())))"
>>> # Report a noSuchName SNMP error
>>> rsp['pdu']['get_response']['error_index'].set(1)
>>> rsp['pdu']['get_response']['error_status'].set(2)
>>> # ...for the following OID
>>> rsp['pdu']['get_response']['variable_bindings'].append(v1.VarBind(name=v1.ObjectName('1.3.6.1.2.1.1.1.0'), value=v1.ObjectSyntax(simple=v1.SimpleSyntax(integer=v1.Integer(1)))))
>>> rsp.encode()
"0'\002\001\000\004\006public\242\032\002\001\002\002\001\002\002\001\0010\0170\015\006\010+\006\001\002\001\001\001\000\002\001\001"
>>>


ilya@glas.net