From 0e7ea11b50259f6272dc2a5b0139e4c44b44f4b7 Mon Sep 17 00:00:00 2001 From: sunilkumarn417 Date: Fri, 19 Jun 2020 10:16:46 +0530 Subject: [PATCH] Fixed empty string split issue Signed-off-by: sunilkumarn417 --- teuthology/orchestra/daemon/systemd.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/teuthology/orchestra/daemon/systemd.py b/teuthology/orchestra/daemon/systemd.py index c202669fbe..8d43520cf5 100644 --- a/teuthology/orchestra/daemon/systemd.py +++ b/teuthology/orchestra/daemon/systemd.py @@ -63,9 +63,15 @@ class SystemDState(DaemonState): def parse_line(line): key, value = line.strip().split('=', 1) return {key.strip(): value.strip()} + show_dict = dict() + for line in output.split('\n'): + # skip empty and commented string + if not line or line.startswith("#"): + continue show_dict.update(parse_line(line)) + active_state = show_dict['ActiveState'] sub_state = show_dict['SubState'] if active_state == 'active': -- 2.39.5