aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2018-06-21 16:31:56 +0100
committerBryn M. Reeves <bmr@redhat.com>2018-06-21 16:31:56 +0100
commit9742617247236bc0767549c4f9bf75cd576e3640 (patch)
tree4686a1a9af30ee55321866523f0d251e8482d974
parenta05905e41dd4486669858ea913f48803e1bc5614 (diff)
downloadsos-9742617247236bc0767549c4f9bf75cd576e3640.tar.gz
[policies] handle ValueError in sos.policies.load_presets()
If we encounter a JSON error while loading a preset skip that file and continue to load any other valid preset files. Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/policies/__init__.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/sos/policies/__init__.py b/sos/policies/__init__.py
index 14ed2a07..ca9b181a 100644
--- a/sos/policies/__init__.py
+++ b/sos/policies/__init__.py
@@ -596,7 +596,11 @@ No changes will be made to system configuration.
for preset_path in os.listdir(presets_path):
preset_path = os.path.join(presets_path, preset_path)
- preset_data = json.load(open(preset_path))
+ try:
+ preset_data = json.load(open(preset_path))
+ except ValueError:
+ continue
+
for preset in preset_data.keys():
pd = PresetDefaults(preset, opts=SoSOptions())
data = preset_data[preset]