Skip to content

Commit

Permalink
on_result_base
Browse files Browse the repository at this point in the history
  • Loading branch information
joente committed Sep 29, 2023
1 parent a0173ad commit 6aebf3b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
30 changes: 13 additions & 17 deletions lib/snmpquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from asyncsnmplib.exceptions import SnmpException
from asyncsnmplib.exceptions import SnmpNoAuthParams
from asyncsnmplib.exceptions import SnmpNoConnection
from asyncsnmplib.mib.utils import on_result
from asyncsnmplib.mib.utils import on_result_base
from asyncsnmplib.v3.auth import AUTH_PROTO
from asyncsnmplib.v3.encr import PRIV_PROTO
from libprobe.asset import Asset
Expand Down Expand Up @@ -133,22 +133,18 @@ async def snmpquery(
raise
else:
results = {}
try:
for oid in queries:
result = await cl.walk(oid)
try:
name, result = on_result(oid, result)
except Exception as e:
msg = str(e) or type(e).__name__
raise ParseResultException(
f'Failed to parse result. Exception: {msg}'
)
else:
results[name] = result
except Exception:
raise
else:
return results
for oid in queries:
result = await cl.walk(oid)
try:
name, result = on_result_base(oid, result)
except Exception as e:
msg = str(e) or type(e).__name__
raise ParseResultException(
f'Failed to parse result. Exception: {msg}'
)
else:
results[name] = result
return results
finally:
# safe to close whatever the connection status is
cl.close()
2 changes: 1 addition & 1 deletion lib/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Version string. Examples:
# '3.0.0'
# '3.0.0-alpha9'
__version__ = '3.0.0-alpha3'
__version__ = '3.0.0-alpha4'

0 comments on commit 6aebf3b

Please sign in to comment.