statd: also silence JSONDecodeError on check=False

In d616623a an attempt to silence bogus return values from mctl, when
multicast snooping is disabled on a bridge.  That helped get data back
for operational to produce `show interfaces` *with* a bridge and ports
but still emitted bogus log warnings.

This patch addresses that by checking 'check' on JSONDcodeError as well
before emitting any log error.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2024-09-26 15:49:45 +02:00
parent 10ef7c5fda
commit e483d295da
+3 -2
View File
@@ -137,8 +137,9 @@ def run_json_cmd(cmd, testfile, default=None, check=True):
return default
raise
except json.JSONDecodeError as err:
logger.error(f"failed parsing JSON output of command: {' '.join(cmd)}"
f", error: {err}")
if check is True:
logger.error("failed parsing JSON output of command: "
f"{' '.join(cmd)}, error: {err}")
if default is not None:
return default
raise