aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2022-08-19 13:33:02 -0400
committerJake Hunsaker <jhunsake@redhat.com>2022-09-28 09:48:46 -0400
commit3f586b776e44cdc9d3b4aaa1e7b0d53fecf0acde (patch)
treef31aff7603e9ddc0be19d47ea7a32f795941fd8f
parent5aa750e914ad6a2b37f8c4220fb2c1b9bd25f029 (diff)
downloadsos-3f586b776e44cdc9d3b4aaa1e7b0d53fecf0acde.tar.gz
[unpackaged] Move unpackaged file generation to `collect()`
Moves the generation of the unpackaged file list and resulting file to `collect()`, and out of `setup()`. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
-rw-r--r--sos/report/plugins/unpackaged.py31
1 files changed, 16 insertions, 15 deletions
diff --git a/sos/report/plugins/unpackaged.py b/sos/report/plugins/unpackaged.py
index 24203c4b..7338689b 100644
--- a/sos/report/plugins/unpackaged.py
+++ b/sos/report/plugins/unpackaged.py
@@ -19,7 +19,7 @@ class Unpackaged(Plugin, RedHatPlugin):
'package manager')
plugin_name = 'unpackaged'
- def setup(self):
+ def collect(self):
def get_env_path_list():
"""Return a list of directories in $PATH.
@@ -69,19 +69,20 @@ class Unpackaged(Plugin, RedHatPlugin):
if not self.test_predicate(cmd=True):
return
- paths = get_env_path_list()
- all_fsystem = []
- all_frpm = set(
- os.path.realpath(x) for x in self.policy.mangle_package_path(
- self.policy.package_manager.all_files()
- ) if any([x.startswith(p) for p in paths])
- )
-
- for d in paths:
- all_fsystem += all_files_system(d)
- not_packaged = [x for x in all_fsystem if x not in all_frpm]
- not_packaged_expanded = format_output(not_packaged)
- self.add_string_as_file('\n'.join(not_packaged_expanded), 'unpackaged',
- plug_dir=True)
+ with self.collection_file('unpackaged') as ufile:
+ paths = get_env_path_list()
+ all_fsystem = []
+ all_frpm = set(
+ os.path.realpath(x) for x in self.policy.mangle_package_path(
+ self.policy.package_manager.all_files()
+ ) if any([x.startswith(p) for p in paths])
+ )
+
+ for d in paths:
+ all_fsystem += all_files_system(d)
+ not_packaged = [x for x in all_fsystem if x not in all_frpm]
+ not_packaged_expanded = format_output(not_packaged)
+
+ ufile.write('\n'.join(not_packaged_expanded))
# vim: set et ts=4 sw=4 :