diff options
author | Bryn M. Reeves <bmr@redhat.com> | 2013-08-21 16:42:03 +0100 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2013-08-21 16:42:03 +0100 |
commit | 80ad174d5d7c712dff9a3781e02ecfa5f8e9e368 (patch) | |
tree | aef27af67b1bc2ba1f9ce415203d896d1d616a97 | |
parent | e109475ef82607345ffbbcabba1d5d471400b9ac (diff) | |
download | sos-80ad174d5d7c712dff9a3781e02ecfa5f8e9e368.tar.gz |
Add Plugin method to create new command output directories
Some plug-ins want to store command output in subdirectories of
their 'sos_commands/<plugin>/' directory. Currently there are
various hand-rolled methods to build this in different plug-ins.
Add a single method to the base Plugin class that builds the
correct path string and recursively creates the directories via
os.makedirs() in a single step.
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r-- | sos/plugins/__init__.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py index d5bb3c0b..0e9e4c3d 100644 --- a/sos/plugins/__init__.py +++ b/sos/plugins/__init__.py @@ -502,6 +502,11 @@ class Plugin(object): return os.path.join(self.archive.get_tmp_dir(), 'sos_commands', self.name()) + def make_cmd_dirs(self, path): + """Recursively create new subdirectories under this plug-in's + command output path.""" + os.makedirs(self.get_cmd_path(), path) + def file_grep(self, regexp, *fnames): """Returns lines matched in fnames, where fnames can either be pathnames to files to grep through or open file objects to grep through |