pief/python-netsnmpagent — pull request #9 by mk23 (2013-10-01 00:58:56+00:00)
Title: Fix pief/python-netsnmpagent#8: Set watcher data_size on update()

There are actually three small issues here:
* libnsX.netsnmp_watcher_info structure doesn't have any _fields_ so watcher.contents is empty
* setting watcher.max_size (instead of watcher.contents.max_size) silently does nothing
* WATCHER_SIZE_STRLEN flag doesn't exist in net-snmp < 5.7 so data_size was getting set once and never updating.

This pull request fixes all three. The one caveat is on net-snmp 5.7, there's another field in netsnmp_watcher_info that I've left out. It's not explicitely used so I felt it was safe to do so. For completion/correctness, it can be added but only if version is < 5.7, which can be tested with something like:

```python
libns = ctypes.cdll.LoadLibrary(ctypes.util.find_library("netsnmp"))
for f in [ libns.netsnmp_get_version ]:
f.argtypes = []
f.restype = ctypes.c_char_p

version = tuple(int(i) for i in libns.netsnmp_get_version().split('.'))
print version, version < (5, 7)
```

But that felt like a lot of code for not very much gain.