diff options
author | shnavid <shnavid@ef72aa8b-4018-0410-8976-d6e080ef94d8> | 2007-06-15 11:59:03 +0000 |
---|---|---|
committer | shnavid <shnavid@ef72aa8b-4018-0410-8976-d6e080ef94d8> | 2007-06-15 11:59:03 +0000 |
commit | 8a72411156d4fe6cdca99317c2f6b87a46100286 (patch) | |
tree | 841cde5d71ff1f7d8dc36477e1b843e2229fbd83 /src/lib | |
parent | fdaedd36fca0e15829d1dca06ee7a0c95541c59f (diff) | |
download | sos-8a72411156d4fe6cdca99317c2f6b87a46100286.tar.gz |
* Initial commit of XML reporting to gather details about commands executed and files gathered.
git-svn-id: svn+ssh://svn.fedorahosted.org/svn/sos/trunk@144 ef72aa8b-4018-0410-8976-d6e080ef94d8
Diffstat (limited to 'src/lib')
-rwxr-xr-x | src/lib/sos/helpers.py | 4 | ||||
-rw-r--r-- | src/lib/sos/plugintools.py | 20 | ||||
-rwxr-xr-x | src/lib/sos/policyredhat.py | 2 |
3 files changed, 20 insertions, 6 deletions
diff --git a/src/lib/sos/helpers.py b/src/lib/sos/helpers.py index 5524c0e4..8ba503c1 100755 --- a/src/lib/sos/helpers.py +++ b/src/lib/sos/helpers.py @@ -26,6 +26,7 @@ helper functions used by sosreport and plugins """ import os, popen2, fcntl, select, itertools, sys +from time import time from tempfile import mkdtemp def importPlugin(pluginname, name): @@ -60,6 +61,7 @@ def sosGetCommandOutput(command): """ Execute a command and gather stdin, stdout, and return status. Adapted from Python Cookbook - O'Reilly """ + stime = time() child = popen2.Popen3(command, 1) # Capture stdout and stderr from command child.tochild.close() # don't need to write to child's stdin outfile = child.fromchild @@ -89,7 +91,7 @@ def sosGetCommandOutput(command): break select.select([], [], [], .1) # Allow a little time for buffers to fill err = child.wait() - return (err, ''.join(outdata), ''.join(errdata)) + return (err, ''.join(outdata), ''.join(errdata), time()-stime) # this needs to be made clean and moved to the plugin tools, so diff --git a/src/lib/sos/plugintools.py b/src/lib/sos/plugintools.py index 5c301ed6..27203765 100644 --- a/src/lib/sos/plugintools.py +++ b/src/lib/sos/plugintools.py @@ -150,6 +150,7 @@ class PluginBase: try: dstslname, abspath = self.__copyFile(srcpath) self.copiedFiles.append({'srcpath':srcpath, 'dstpath':dstslname, 'symlink':"yes", 'pointsto':link}) + self.cInfo['xmlreport'].add_file(srcpath,os.stat(srcpath)) except SystemExit: raise SystemExit except KeyboardInterrupt: @@ -194,7 +195,7 @@ class PluginBase: """ try: # pylint: disable-msg = W0612 - status, shout, sherr = sosGetCommandOutput("/bin/cp --parents -p " + src +" " + self.cInfo['dstroot']) + status, shout, sherr, runtime = sosGetCommandOutput("/bin/cp --parents -p " + src +" " + self.cInfo['dstroot']) if status: self.cInfo['soslog'].debug(shout) self.cInfo['soslog'].debug(sherr) @@ -277,7 +278,7 @@ class PluginBase: return # pylint: disable-msg = W0612 - status, shout, sherr = sosGetCommandOutput(prog) + status, shout, sherr, runtime = sosGetCommandOutput(prog) return status def runExe(self, exe): @@ -320,17 +321,28 @@ class PluginBase: return # pylint: disable-msg = W0612 - status, shout, sherr = sosGetCommandOutput(exe) + status, shout, sherr, runtime = sosGetCommandOutput(exe) outfn = self.makeCommandFilename(exe) outfd = open(outfn, "w") outfd.write(shout) outfd.close() - self.cInfo['soslog'].debug(sherr) + outfn = outfn[len(self.cInfo['cmddir'])+1:] + if len(sherr) > 0: + errfn = outfn + ".err" + outfd = open(errfn, "w") + outfd.write(sherr) + outfd.close() + errfn = errfn[len(self.cInfo['cmddir'] + "/" )+1:] + self.cInfo['soslog'].debug(sherr) + else: + errfn = None + # sosStatus(status) # save info for later self.executedCommands.append({'exe': exe, 'file':outfn}) # save in our list + self.cInfo['xmlreport'].add_command(cmdline=exe,exitcode=status,f_stdout=outfn,f_stderr=errfn,runtime=runtime) return outfn def writeTextToCommand(self, exe, text): diff --git a/src/lib/sos/policyredhat.py b/src/lib/sos/policyredhat.py index 08e0f9b3..80643576 100755 --- a/src/lib/sos/policyredhat.py +++ b/src/lib/sos/policyredhat.py @@ -111,7 +111,7 @@ class SosPolicy: os.chdir(ourtempdir) oldmask = os.umask(077) # pylint: disable-msg = W0612 - status, shout, sherr = sosGetCommandOutput(tarcmd) + status, shout, sherr, runtime = sosGetCommandOutput(tarcmd) os.umask(oldmask) os.chdir(curwd) os.system("/bin/mv %s %s" % (aliasdir, self.cInfo['dstroot'])) |