Fixed failure with fetch-stats

This patch fails nicely with the fetch-stats if it can't connect
with the rpc server on the other end.
This commit is contained in:
Hemna 2024-03-12 10:37:17 -04:00
parent cb9456b29d
commit 10d023dd7b
1 changed files with 5 additions and 1 deletions

View File

@ -58,7 +58,11 @@ def fetch_stats(ctx, host, port, magic_word):
with console.status(msg):
client = rpc_client.RPCClient(host, port, magic_word)
stats = client.get_stats_dict()
console.print_json(data=stats)
if stats:
console.print_json(data=stats)
else:
LOG.error(f"Failed to fetch stats via RPC aprsd server at {host}:{port}")
return
aprsd_title = (
"APRSD "
f"[bold cyan]v{stats['aprsd']['version']}[/] "