From 3586b9f0c949b3c5a2cdbc4a77047e16e6ca6d22 Mon Sep 17 00:00:00 2001 From: LeoVerto Date: Mon, 10 Sep 2018 18:45:36 +0200 Subject: [PATCH] Fix KeyError on unused networks --- docker-net-graph.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docker-net-graph.py b/docker-net-graph.py index 11ecb0c..bd0cab8 100755 --- a/docker-net-graph.py +++ b/docker-net-graph.py @@ -61,14 +61,15 @@ def generate_graph(verbose: bool, file: str): try: gateway = net['IPAM']['Config'][0]['Gateway'] - except IndexError: - gateway = None + except KeyError: + # This network doesn't seem to be used, skip it + continue internal = "" try: if net['Internal']: internal = "| Internal " - except IndexError: + except KeyError: pass isolated = ""