From 26c4ef3f4327b2ce6809f69280e24495e3ced147 Mon Sep 17 00:00:00 2001 From: Jeremy Schulman Date: Tue, 26 Sep 2023 14:58:30 -0400 Subject: [PATCH] added exception handling on httpx.ReadTimeout (#46) --- netcam_aioeos/bgp_peering/eos_checks_bgp_peering.py | 4 +++- netcam_aioeos/bgp_peering/eos_checks_bgp_routers.py | 4 +++- netcam_aioeos/config/eos_dcfg.py | 4 ++++ pyproject.toml | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/netcam_aioeos/bgp_peering/eos_checks_bgp_peering.py b/netcam_aioeos/bgp_peering/eos_checks_bgp_peering.py index 41ef1a6..33959fe 100644 --- a/netcam_aioeos/bgp_peering/eos_checks_bgp_peering.py +++ b/netcam_aioeos/bgp_peering/eos_checks_bgp_peering.py @@ -33,7 +33,9 @@ async def check_neeighbors( results: CheckResultsCollection = list() checks = check_collection.checks - dev_data = await dut.api_cache_get(key="bgp-summary", command="show ip bgp summary vrf all") + dev_data = await dut.api_cache_get( + key="bgp-summary", command="show ip bgp summary vrf all" + ) for nei_check in checks: _check_bgp_neighbor( diff --git a/netcam_aioeos/bgp_peering/eos_checks_bgp_routers.py b/netcam_aioeos/bgp_peering/eos_checks_bgp_routers.py index f4c7d4c..de53671 100644 --- a/netcam_aioeos/bgp_peering/eos_checks_bgp_routers.py +++ b/netcam_aioeos/bgp_peering/eos_checks_bgp_routers.py @@ -48,7 +48,9 @@ async def check_bgp_neighbors( checks = check_bgp_routers.checks dut: EOSDeviceUnderTest = self - dev_data = await dut.api_cache_get(key="bgp-summary", command="show ip bgp summary vrf all") + dev_data = await dut.api_cache_get( + key="bgp-summary", command="show ip bgp summary vrf all" + ) for rtr_chk in checks: _check_router_vrf(dut=dut, check=rtr_chk, dev_data=dev_data, results=results) diff --git a/netcam_aioeos/config/eos_dcfg.py b/netcam_aioeos/config/eos_dcfg.py index 7ef7ae4..f4986d6 100644 --- a/netcam_aioeos/config/eos_dcfg.py +++ b/netcam_aioeos/config/eos_dcfg.py @@ -18,6 +18,8 @@ from typing import Optional +import httpx + # ----------------------------------------------------------------------------- # Public Imports # ----------------------------------------------------------------------------- @@ -122,6 +124,8 @@ async def config_check(self, replace: Optional[bool | None] = None) -> str | Non ) except RuntimeError as exc: errors = exc.args[0] + except httpx.ReadTimeout: + errors = f"Read timeout after {self.eapi.timeout}. Increase config.timeout" else: errors = None diff --git a/pyproject.toml b/pyproject.toml index 6b1e595..bf1f99b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "netcam-aioeos" -version = "0.6.6" +version = "0.6.7" description = "NetCAD/CAM - Arista EOS/eAPI asyncio driver" readme = "README.md" authors = ["Jeremy Schulman"]