From 200e9a59ffaefdc046f29b299ca0b2e13f791ffe Mon Sep 17 00:00:00 2001 From: Scott Davidson <49713135+sd109@users.noreply.github.com> Date: Mon, 18 Dec 2023 19:41:23 +0000 Subject: [PATCH] Try catching StopIteration explicitly --- capi_janitor/openstack/openstack.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/capi_janitor/openstack/openstack.py b/capi_janitor/openstack/openstack.py index fc4d471..096c5d8 100644 --- a/capi_janitor/openstack/openstack.py +++ b/capi_janitor/openstack/openstack.py @@ -173,15 +173,14 @@ async def __aenter__(self): # ) # for entry in response.json()["catalog"] # } + self._endpoints = {} try: catalog = response.json()["catalog"] - endpoints = {} for entry in catalog: - endpoints[entry["type"]] = [ep["url"] for ep in entry["endpoints"] if ep["interface"] == self._interface] - self._endpoints = endpoints - except Exception as exc: + self._endpoints[entry["type"]] = [ep["url"] for ep in entry["endpoints"] if ep["interface"] == self._interface] + except StopIteration as exc: print(f"Caught: {exc}") - raise + pass return self