The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/python3-lxc/pull/21
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === Just implemented as suggested in the issue, but not sure if this is exactly where we want to catch the error, or if it would be more appropriate somewhere upstream, such as in the `Container` class?
From 1e64954badb5c63390a31ea2f18cb68fc59dd75b Mon Sep 17 00:00:00 2001 From: Andrew Chang <chang331...@gmail.com> Date: Thu, 17 Sep 2020 17:13:12 -0500 Subject: [PATCH] python3-lxc: Change ContainerNetworkList len function to not throw KeyError Signed-off-by: Andrew Chang <chang331...@gmail.com> --- lxc/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lxc/__init__.py b/lxc/__init__.py index ccc4d18..e73c843 100644 --- a/lxc/__init__.py +++ b/lxc/__init__.py @@ -124,7 +124,10 @@ def __getitem__(self, index): return ContainerNetwork(self.container, index) def __len__(self): - values = self.container.get_config_item("lxc.net") + try: + values = self.container.get_config_item("lxc.net") + except KeyError: + values = None if values: return len(values)
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel