Comments (4)
I vaguely remember that I had a problem with generators somewhere, but I don't remember if that was here.
Maybe it was an oversight on my end. An easy way would be to modify it to yield immediately and see how the tests behave
from puresnmp.
I tested the following against my fork and all tests passed in both py2 and py3. I should move the code duplication into an embedded function, but this was just a quick test to see if it would even work.
--- C:/Users/royce3/AppData/Local/Temp/TortoiseGit/__init__-fd35dc5.000.py Sun Feb 11 09:35:47 2018
+++ C:/cvs/puresnmp_remdragon/puresnmp/__init__.py Sun Feb 11 09:31:39 2018
@@ -188,7 +188,15 @@
LOG.debug('%d of %d OIDs need to be continued',
len(unfinished_oids),
len(oids))
- output = group_varbinds(varbinds, requested_oids)
+ yielded = _set([])
+ for v in group_varbinds(varbinds, requested_oids).values():
+ #print ( '1: v={!r}'.format ( v ) )
+ for varbind in v:
+ containment = [varbind.oid in _ for _ in requested_oids]
+ if not any(containment) or varbind.oid in yielded:
+ continue
+ yielded.add(varbind.oid)
+ yield varbind
# As long as we have unfinished OIDs, we need to continue the walk for
# those.
@@ -208,19 +216,15 @@
LOG.debug('%d of %d OIDs need to be continued',
len(unfinished_oids),
len(oids))
- for k, v in group_varbinds(varbinds, next_fetches).items():
- for ko, vo in output.items():
- if k in ko:
- vo.extend(v)
-
- yielded = _set([])
- for v in output.values():
- for varbind in v:
- containment = [varbind.oid in _ for _ in requested_oids]
- if not any(containment) or varbind.oid in yielded:
- continue
- yielded.add(varbind.oid)
- yield varbind
+ for v in group_varbinds(varbinds, next_fetches).values():
+ #print ( '2: v={!r}'.format ( v ) )
+ for varbind in v:
+ containment = [varbind.oid in _ for _ in requested_oids]
+ #print ( '2a: v={!r}, containment={!r}'.format ( v, containment ) )
+ if not any(containment) or varbind.oid in yielded:
+ continue
+ yielded.add(varbind.oid)
+ yield varbind
def set(ip, community, oid, value, port=161, timeout=2):
from puresnmp.
Looks good to me.
from puresnmp.
If you like you could create a PR from this and I'll see to it that I'll get it merged. Just do a bit of cleanup first, like removing the commented print statements & checking that it's mostly PEP8 compliant.
from puresnmp.
Related Issues (20)
- v2.0.0rc1 on pip doesn't contain the necessary files. HOT 16
- when v2.x can install from pip HOT 3
- SNMPv3 authPriv not working for specific vendor. HOT 19
- ERROR: No matching distribution found for pack==1.1,==1.3; extra == "rest" HOT 3
- Cookbook link broken / trap example HOT 1
- Trap receiver throws exception HOT 1
- table and bulktable api is not identical
- Circular dependency error?
- get("1.3.6.1.2.1.2.1.0") good; get(OID("1.3.6.1.2.1.2.1.0")) throws exception HOT 1
- NotImplementedError: Decoding is not yet implemented on <class 'puresnmp.x690.types.BitString'>
- Implement RFC-3411 (for SNMPv3 and SNMPv1 support) HOT 3
- puresnmp.get throws "empty" exceptions
- multiget to SNMPv1 device timeout HOT 6
- puresnmp 1.10.2 depends on typing module HOT 10
- Wrong type signatures in master branch HOT 3
- Issue with importing typing library in Python 3.7 HOT 1
- bulkwalk loops forever if a buggy snmp server loops HOT 7
- Asyncio Traps HOT 2
- IndexError: list index out of range
- IndexError: list index out of range
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from puresnmp.