Ensure proper data-type in "pythonic" API
@@ -17,6 +17,7 @@ variable types unmodified which are all subclasses of
from __future__ import unicode_literals
+
import logging
from collections import OrderedDict
from datetime import datetime, timedelta
@@ -25,6 +26,7 @@ from typing import TYPE_CHECKING
from . import raw
from ..pdu import VarBind
from ..util import BulkResult
+from ..x690.types import Type
from ..x690.util import tablify
if TYPE_CHECKING: # pragma: no cover
@@ -107,7 +109,7 @@ def walk(ip, community, oid, port=161, timeout=2):
def multiwalk(ip, community, oids, port=161, timeout=2,
- fetcher=raw.multigetnext):
+ fetcher=multigetnext):
# type: (str, str, List[str], int, int, Callable[[str, str, List[str], int, int], List[VarBind]]) -> Generator[VarBind, None, None]
"""
Delegates to :py:func:`~puresnmp.api.raw.multiwalk` but returns simple
@@ -117,6 +119,8 @@ def multiwalk(ip, community, oids, port=161, timeout=2,
"""
raw_output = raw.multiwalk(ip, community, oids, port, timeout, fetcher)
for oid, value in raw_output:
+ if isinstance(value, Type):
+ value = value.pythonize()
yield VarBind(oid, value)
@@ -183,7 +187,7 @@ def bulkwalk(ip, community, oids, bulk_size=10, port=161):
ip, community, oids, port=port,
fetcher=raw._bulkwalk_fetcher(bulk_size)) # pylint: disable=protected-access
for oid, value in result:
- yield VarBind(oid, value.pythonize())
+ yield VarBind(oid, value)
def table(ip, community, oid, port=161, num_base_nodes=0):
