Giter VIP home page Giter VIP logo

Comments (7)

vincentbernat avatar vincentbernat commented on May 23, 2024

The MIB says that cdpCacheDevicePort is a DisplayString. Such a type mandates the use of ASCII charset, hence the error. The difference you get is a bug and you should get the same exception during your first try.

With the not-yet-released latest version of Snimpy, thanks to @Daemonae, it is possible to fix the type with something like this:

m.cdpCacheDevicePort.proxy.typeName = 'somethingelse'

You'll have to find what somethingelse could be. Unfortunately, it is not possible to use OCTET STRING here. SNMPv2-TC defines TAddress which is quite like an OCTET STRING.

The other way around is to fix the MIB as the type is not a DisplayString. Change the SYNTAX to OCTET STRING to fix this "problem". I have just pushed 0.8.4 with those changes so that you can test this workaround.

from snimpy.

mrichar1 avatar mrichar1 commented on May 23, 2024

Hi,

Thanks for such a quick answer!

I've tried out the potential fixes - editing the MIB and changing DisplayString to OCTET STRING works as expected.

However, setting:

m.cdpCacheDevicePort.proxy.typeName = 'TAddress'

Still returns the same error. Is this related to the 'base type' still being DisplayString?

One other question - would you consider adding a way to return the 'raw' value with no coercion/casting? I know this is the wrong place to fix the problem, but given that vendors often play 'fast and loose' and don't obey the standards/match the MIBs, it could potentially be useful, even just for debugging these kinds of situations?

Many thanks once again for a quick and detailed response!

from snimpy.

vincentbernat avatar vincentbernat commented on May 23, 2024

Yes, the base type is still the one of display strings (ie types with a format), so the workaround won't work.

As for disabling type coercion, yes, we can try to do that when outputting values. This could be done in a context or in a special session (RawSession for example).

from snimpy.

vincentbernat avatar vincentbernat commented on May 23, 2024

The session stuff is the wrong abstraction. Let me think a bit. This could also be just a parameter for the manager.

from snimpy.

mrichar1 avatar mrichar1 commented on May 23, 2024

That would work - I was mostly thinking of cases where you might want to try getting the coerced value, and if that failed, get the raw value - not sure how that could be implemented:

try:
    # Get the coerced/converted value as normal
    x = m.Foo[id]
except UnicodeDecodeError:
    # Something went wrong with conversion - get the raw value
    x = ???

I could imagine doing something like:

```python
m.getRaw(True)
x = m.Foo[id]
m.getRaw(False)

Or maybe a raw method on the manager?

m.raw.Foo[id]

Just some quick thinking around the idea, so take it all with a pinch of salt :-)

from snimpy.

mrichar1 avatar mrichar1 commented on May 23, 2024

👍 many thanks!

from snimpy.

vincentbernat avatar vincentbernat commented on May 23, 2024

With the latest commit, you can pass loose=True when creating a manager.

from snimpy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.