Closed banjaxedben closed 5 years ago
Python 3.6.8, pysnmp 4.4.11 Ref: http://snmplabs.com/pysnmp/docs/api-reference.html#octetstring-type
>>> from pysnmp.proto.rfc1902 import OctetString >>> OctetString(hexvalue='000A14000000') <OctetString schema object, tagSet <TagSet object, tags 0:0:4>, subtypeSpec <ConstraintsIntersection object, consts <ValueSizeConstraint object, consts 0, 65535>>, hexvalue 000A14000000, encoding iso-8859-1> >>> l = [OctetString(hexValue='000A14000000')] >>> l [<OctetString value object, tagSet <TagSet object, tags 0:0:4>, subtypeSpec <ConstraintsIntersection object, consts <ValueSizeConstraint object, consts 0, 65535>>, encoding iso-8859-1, payload [0x000a14000000]>] >>> d = {'1.3.6.1.2.1.2.2.1.6.1': OctetString(hexValue='000A14000000')} >>> d {'1.3.6.1.2.1.2.2.1.6.1': <OctetString value object, tagSet <TagSet object, tags 0:0:4>, subtypeSpec <ConstraintsIntersection object, consts <ValueSizeConstraint object, consts 0, 65535>>, encoding iso-8859-1, payload [0x000a14000000]>}
i.e. When using OctetString directly on a string, I get "hexvalue 000A14000000". When using OctetString inside an iterable, I get "payload [0x000a14000000]".
Can you explain this?
You are using the wrong keyword argument - hexvalue, should be hexValue. That causes uninitialized OctetString object.
hexvalue
hexValue
OctetString
Python 3.6.8, pysnmp 4.4.11 Ref: http://snmplabs.com/pysnmp/docs/api-reference.html#octetstring-type
i.e. When using OctetString directly on a string, I get "hexvalue 000A14000000". When using OctetString inside an iterable, I get "payload [0x000a14000000]".
Can you explain this?