From 9742617247236bc0767549c4f9bf75cd576e3640 Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Thu, 21 Jun 2018 16:31:56 +0100 Subject: [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 --- sos/policies/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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] -- cgit