-
-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UnicodeDecodeError on value conversion #24
Comments
This matches what is done everywhere else. Unfortunately, this may rise some additional problems when the MIB is inexact. See #24 for example.
The MIB says that With the not-yet-released latest version of Snimpy, thanks to @Daemonae, it is possible to fix the type with something like this:
You'll have to find what The other way around is to fix the MIB as the type is not a |
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! |
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 ( |
The session stuff is the wrong abstraction. Let me think a bit. This could also be just a parameter for the manager. |
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 :-) |
👍 many thanks! |
With the latest commit, you can pass |
I'm currently using snimpy (in a python2.6 virtualenv) to pull the cdp info from a variety of network devices.
Having set up a manager object:
I then want to get cdpCacheDevicePort:
Results:
However, if I iterate over another related oid, and use it's index for that iteration to query the value of this field, I get an error when it reaches the 'hex format' values:
Results:
It looks like in the iteration the raw value is returned - however when asking for a specific instance, some formatting is done (e.g '3' versus '<String: 3>'). Is this a bug? Or Is there a way to avoid this behaviour (without having to iterate over the oid to get a specific value) and always get the raw value?
Thanks!
The text was updated successfully, but these errors were encountered: