def collectOutputNow(self, exe, suggest_filename=None, root_symlink=False, timeout=300): """ Execute a command and save the output to a file for inclusion in the report """ if self.cInfo['cmdlineopts'].profiler: start_time = time() # pylint: disable-msg = W0612 status, shout, runtime = sosGetCommandOutput(exe, timeout=timeout) if suggest_filename: outfn = self.makeCommandFilename(suggest_filename) else: outfn = self.makeCommandFilename(exe) if not (status == 127 or status == 32512): # if not command_not_found outfn_strip = outfn[len(self.cInfo['cmddir'])+1:] self.archive.add_string(shout, outfn) else: self.soslog.debug("could not run command: %s" % exe) outfn = None outfn_strip = None # save info for later self.executedCommands.append({'exe': exe, 'file':outfn_strip}) # save in our list self.cInfo['xmlreport'].add_command(cmdline=exe,exitcode=status,f_stdout=outfn_strip,runtime=runtime) if self.cInfo['cmdlineopts'].profiler: time_passed = time() - start_time self.proflog.debug("output: %-75s time: %f" % (exe, time_passed)) return outfn
def collectOutputNow(self, exe, suggest_filename=None, root_symlink=False, timeout=300): """ Execute a command and save the output to a file for inclusion in the report """ if self.cInfo['cmdlineopts'].profiler: start_time = time() # pylint: disable-msg = W0612 status, shout, runtime = sosGetCommandOutput(exe, timeout=timeout) if suggest_filename: outfn = self.makeCommandFilename(suggest_filename) else: outfn = self.makeCommandFilename(exe) if not (status == 127 or status == 32512): # if not command_not_found outfn_strip = outfn[len(self.cInfo['cmddir'])+1:] self.archive.add_string(shout, outfn) if root_symlink: self.archive.add_link(outfn, root_symlink) else: self.soslog.debug("could not run command: %s" % exe) outfn = None outfn_strip = None # save info for later self.executedCommands.append({'exe': exe, 'file':outfn_strip}) # save in our list self.cInfo['xmlreport'].add_command(cmdline=exe,exitcode=status,f_stdout=outfn_strip,runtime=runtime) if self.cInfo['cmdlineopts'].profiler: time_passed = time() - start_time self.proflog.debug("output: %-75s time: %f" % (exe, time_passed)) return outfn
def callExtProg(self, prog): """ Execute a command independantly of the output gathering part of sosreport """ # pylint: disable-msg = W0612 status, shout, runtime = sosGetCommandOutput(prog) return (status, shout, runtime)
def callExtProg(self, prog, timeout=300): """Execute a command independantly of the output gathering part of sosreport. """ # pylint: disable-msg = W0612 return sosGetCommandOutput(prog, timeout)
def test_output_non_exe(self): path = os.path.join(TEST_DIR, 'utility_tests.py') ret, out, junk = sosGetCommandOutput(path) self.assertEquals(ret, 127) self.assertEquals(out, "")
def test_output(self): path = os.path.join(TEST_DIR, 'test_exe.py') ret, out, junk = sosGetCommandOutput(path) self.assertEquals(ret, 0) self.assertEquals(out, "executed\n")
def test_output(self): path = os.path.join(TEST_DIR, 'test_exe.py') ret, out, junk = sosGetCommandOutput(path) self.assertEquals(ret, 0) self.assertEquals(out, "executed")