From 61b058bcfcec6281c5cfcd146e2875615032907a Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Mon, 10 Jul 2023 12:19:23 +0200 Subject: [PATCH] Fix mishandling of BirdErrors in BirdSocketTopologyProvider --- birdvisu/providers.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/birdvisu/providers.py b/birdvisu/providers.py index e9c04af..8a02927 100644 --- a/birdvisu/providers.py +++ b/birdvisu/providers.py @@ -454,8 +454,8 @@ class ProcessTopologyProvider(TopologyProvider): class BirdMultipleInstancesError(BirdError): """BIRD has multiple known OSPF's running. - This exception is intended to be created from existing BirdError. (We do - not re-raise, because we know what has happened.)""" + This exception is intended to be created from existing BirdError. (We stil + re-raise, so the error message is sane.)""" def __init__(self, orig_exc: BirdError, protocols: list[str]): for attr in ['code', 'start', 'end', 'text']: val = getattr(orig_exc, attr) @@ -493,9 +493,9 @@ class BirdSocketTopologyProvider(TopologyProvider): try: response = sock.request(request) except BirdError as e: - if e.text == 'There are multiple OSPF protocols running': + if e.text == 'There are multiple OSPF protocols running\n': protocols = self.find_runing_ospf(sock) - raise BirdMultipleInstancesError(e, protocols) + raise BirdMultipleInstancesError(e, protocols) from e raise parser = OspfFileTopologyParser(version=self.version, area=self.area) return parser.parse(response.text, freeze=self.freeze) @@ -507,7 +507,7 @@ class BirdSocketTopologyProvider(TopologyProvider): assert len(resp.codes) == 3 assert resp.codes[0] == ((1,1), '2002') assert resp.codes[1][1] == '1002' - lines = resp.splitlines() + lines = resp.text.splitlines() header = lines[0] fields = header.split() assert fields[0] == 'Name'