From 79afaf79d23096d24b0c2dabeb1e217d0c2b0102 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 26 Sep 2023 12:58:46 +0200 Subject: [PATCH] fix --- asyncsnmplib/client.py | 2 +- asyncsnmplib/utils.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/asyncsnmplib/client.py b/asyncsnmplib/client.py index 731ef75..67a24c9 100644 --- a/asyncsnmplib/client.py +++ b/asyncsnmplib/client.py @@ -177,7 +177,7 @@ def __init__( try: self._priv_proto = PRIV_PROTO[priv_proto] except KeyError: - raise Exception('Supply valid auth_proto') + raise Exception('Supply valid priv_proto') if self._priv_proto and not self._auth_proto: raise Exception('Supply auth_proto') if self._auth_proto: diff --git a/asyncsnmplib/utils.py b/asyncsnmplib/utils.py index 9a08987..a320368 100644 --- a/asyncsnmplib/utils.py +++ b/asyncsnmplib/utils.py @@ -106,6 +106,11 @@ async def snmp_queries( logging.warning(f'invalid snmpv3 client config {address}: {e}') raise InvalidClientConfigException elif version == '1': + community = config.get('community', 'public') + if isinstance(community, dict): + community = community.get('secret') + if not isinstance(community, str): + raise TypeError('SNMP community must be a string.') cl = SnmpV1( host=address, community=community, @@ -130,7 +135,7 @@ async def snmp_queries( except Exception as e: msg = str(e) or type(e).__name__ raise ParseResultException( - f'parse result error: {msg}') + f'Failed to parse result. Exception: {msg}') else: results[name] = parsed_result return results