From d65099fde910102a8ef47e86a32418797a55345e Mon Sep 17 00:00:00 2001 From: Jake Hunsaker Date: Thu, 15 Nov 2018 13:51:37 -0500 Subject: [presets] Create preset directory if it does not exist When attempting to add a preset when /var/lib/sos/presets does not exist, the attempt will fail. Now, if the directory does not exist, sos will attempt to create it. Resolves: #1480 Signed-off-by: Jake Hunsaker Signed-off-by: Bryn M. Reeves --- sos/policies/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sos/policies/__init__.py b/sos/policies/__init__.py index 8d74caaf..ae85991c 100644 --- a/sos/policies/__init__.py +++ b/sos/policies/__init__.py @@ -385,6 +385,9 @@ class PresetDefaults(object): odict = self.opts.dict() pdict = {self.name: {DESC: self.desc, NOTE: self.note, OPTS: odict}} + if not os.path.exists(presets_path): + os.makedirs(presets_path, mode=0o755) + with open(os.path.join(presets_path, self.name), "w") as pfile: json.dump(pdict, pfile) -- cgit