aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSourabh Jain <sourabhjain@linux.ibm.com>2020-05-06 16:45:40 +0530
committerJake Hunsaker <jhunsake@redhat.com>2020-05-07 10:04:30 -0400
commitd1aa3d8054118b7cd1f01146655df2470de3a64e (patch)
treeabbbcfe483fbec42ddd8aa90b07165086ee84ca3
parentd902e144f094fcfd090f64db615f86811faf12cf (diff)
downloadsos-d1aa3d8054118b7cd1f01146655df2470de3a64e.tar.gz
[policies] Take care of empty lines while parsing /etc/os-release
The check function in CozPolicy class hits the ValueError exception if we have empty lines in /etc/os-release file. Updated the list comprehension used to parse the /etc/os-release file with a if condition to take care of empty lines. Closes: #2045 Resolves: #2046 Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com> Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
-rw-r--r--sos/policies/cos.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/sos/policies/cos.py b/sos/policies/cos.py
index 005bd7bc..d9da0a3d 100644
--- a/sos/policies/cos.py
+++ b/sos/policies/cos.py
@@ -27,7 +27,8 @@ class CosPolicy(LinuxPolicy):
try:
with open('/etc/os-release', 'r') as fp:
- os_release = dict(line.strip().split('=') for line in fp)
+ os_release = dict(line.strip().split('=') for line in fp
+ if line.strip())
id = os_release.get('ID')
return id == 'cos'
except IOError: