You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that despite many of the examples showing it this way, get() (at least) does NOT accept an ObjectIdentifier object - it wants that string and nothing else, raising
AttributeError: 'ObjectIdentifier' object has no attribute 'startswith'
just as OID(OID("1.3.6.1.2.1.2.1.0")) does.
Although most (?) of the puresnmp code appears to pass the oid value around without worrying much about what it is, it all goes wrong when "oid" is an ObjectIdentifier rather than a string like so:
File "/home/snmpmon/rrd/pst2.py", line 8, in example
output = await client.get(oid)
File "/home/snmpmon/.local/lib/python3.9/site-packages/puresnmp/api/pythonic.py", line 68, in get
oid_internal = ObjectIdentifier(oid)
File "/home/snmpmon/.local/lib/python3.9/site-packages/x690/types.py", line 738, in init
and value.startswith(".")
It would seem that mypy OUGHT to be raising heck about passing an ObjectIdentifier into x690's ObjectIdentifier() - does it just not understand the X690Type[str] annotation, perhaps?
Freshly pip installed, x690.version = '1.0.0.post1', puresnmp.version = '2.0.0.post1' on Debian Bullseye with Py3.9
The text was updated successfully, but these errors were encountered:
Apparently all my confusion was caused by all (?) the examples being the "docs" for raw Client, but the advice being to use PyWrapper(Client), which of course I did, so of course OID arguments make it go boom. And this is a problem because the docs are really just method signatures, augmented by those examples. Great practical example of why code makes poor documentation. :-/
For example: Does multiget() always return exactly one value for each OID in exactly the same order? I'd like to be able to assume that, as it's not very useful if it doesn't, but nothing says so. The latter seems to be empirically true, but I haven't tested the former assumption. But at least I can just check len(output) == len(oids) for that possible breakdown. And it's only a further guess that it returns None for oids that don't receive an answer. Hmmm, what if the whole inquiry goes unanswered?
Or I could dive into the code far enough to figure it out, but then I'm back where I was with net-snmp years ago... without the MIB complications, at least.
It seems that despite many of the examples showing it this way, get() (at least) does NOT accept an ObjectIdentifier object - it wants that string and nothing else, raising
AttributeError: 'ObjectIdentifier' object has no attribute 'startswith'
just as OID(OID("1.3.6.1.2.1.2.1.0")) does.
Although most (?) of the puresnmp code appears to pass the oid value around without worrying much about what it is, it all goes wrong when "oid" is an ObjectIdentifier rather than a string like so:
File "/home/snmpmon/rrd/pst2.py", line 8, in example
output = await client.get(oid)
File "/home/snmpmon/.local/lib/python3.9/site-packages/puresnmp/api/pythonic.py", line 68, in get
oid_internal = ObjectIdentifier(oid)
File "/home/snmpmon/.local/lib/python3.9/site-packages/x690/types.py", line 738, in init
and value.startswith(".")
It would seem that mypy OUGHT to be raising heck about passing an ObjectIdentifier into x690's ObjectIdentifier() - does it just not understand the X690Type[str] annotation, perhaps?
Freshly pip installed, x690.version = '1.0.0.post1', puresnmp.version = '2.0.0.post1' on Debian Bullseye with Py3.9
The text was updated successfully, but these errors were encountered: