diff options
author | shnavid <shnavid@ef72aa8b-4018-0410-8976-d6e080ef94d8> | 2007-07-10 15:05:19 +0000 |
---|---|---|
committer | shnavid <shnavid@ef72aa8b-4018-0410-8976-d6e080ef94d8> | 2007-07-10 15:05:19 +0000 |
commit | 7b96b045c9b18efe8513453f1d0344eebe776715 (patch) | |
tree | 85a5b824f3a985129ec20473e7714451a523eddd /src/lib | |
parent | 108b5395ea73f717c59dd3da72e952a97d29c89c (diff) | |
download | sos-7b96b045c9b18efe8513453f1d0344eebe776715.tar.gz |
* added --enableplugin (-e) option to enable plugins which were inactive
* cleaned up plugin activation conditions
* added ability to suggest a name for output file in sos_report instead of auto-generated from command-line
* added root_symlink option to create a symbolic link in sos_report root (and mimic sysreport's structure)
git-svn-id: svn+ssh://svn.fedorahosted.org/svn/sos/trunk@187 ef72aa8b-4018-0410-8976-d6e080ef94d8
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/sos/plugintools.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/lib/sos/plugintools.py b/src/lib/sos/plugintools.py index 1fed8b22..3d80df44 100644 --- a/src/lib/sos/plugintools.py +++ b/src/lib/sos/plugintools.py @@ -288,11 +288,11 @@ class PluginBase: sys.stderr.write("the collectExtOutput() function.\n") pass - def collectExtOutput(self, exe): + def collectExtOutput(self, exe, suggest_filename = None, root_symlink = None): """ Run a program and collect the output """ - self.collectProgs.append(exe) + self.collectProgs.append( (exe,suggest_filename,root_symlink) ) def makeCommandFilename(self, exe): """ The internal function to build up a filename based on a command """ @@ -311,7 +311,7 @@ class PluginBase: return outfn - def collectOutputNow(self, exe): + def collectOutputNow(self, exe, suggest_filename = None, root_symlink = False): """ Execute a command and save the output to a file for inclusion in the report """ @@ -323,11 +323,18 @@ class PluginBase: # pylint: disable-msg = W0612 status, shout, sherr, runtime = sosGetCommandOutput(exe) - outfn = self.makeCommandFilename(exe) + if suggest_filename: + outfn = self.makeCommandFilename(suggest_filename) + else: + outfn = self.makeCommandFilename(exe) outfd = open(outfn, "w") outfd.write(shout) outfd.close() + + if root_symlink: + os.system('cd "%s" && ln -s "%s" "%s"' % (self.cInfo['dstroot'], outfn[len(self.cInfo['dstroot'])+1:], root_symlink)) + if len(sherr) > 0: errfn = outfn + ".err" outfd = open(errfn, "w") @@ -404,10 +411,10 @@ class PluginBase: raise KeyboardInterrupt except Exception, e: self.cInfo['soslog'].log(logging.VERBOSE, "Error copying from pathspec %s (%s)" % (path,e)) - for prog in self.collectProgs: + for (prog,suggest_filename,root_symlink) in self.collectProgs: self.cInfo['soslog'].debug("collecting output of '%s'" % prog) try: - self.collectOutputNow(prog) + self.collectOutputNow(prog, suggest_filename, root_symlink) except SystemExit: raise SystemExit except KeyboardInterrupt: |