Commit Graph

20 Commits

Author SHA1 Message Date
Brian C. Lane e6a2cc605c Improve lmc no-virt error handling
When monitoring log output in livemedia-creator --no-virt it could get
stuck if the output from anaconda stops for some reason.

This changes execReadlines so that it will only read output when it is
available, will monitor the process state, and continue to call the
callback function.

It also adds a final timeout on proc.communicate() so that if Anaconda
becomes stuck and won't exit livemedia-creator will eventually exit.

When the no-virt callback terminates anaconda on an error it now sends a
TERM signal to all of the unshare process' children because just sending
it to unshare doesn't cause anaconda to exit.

(cherry picked from commit 6400515880)
2021-02-08 11:00:23 -08:00
Brian C. Lane 5561bbb3bc executils: Drop bufsize=1 from execReadlines
startProgram is running in binary mode, so bufsize=1 is invalid. The
ExecLineReader class already breaks it up into lines using readline() so
there is no need to change the default buffering.
2020-01-15 10:40:17 -08:00
Brian C. Lane faa65bca3c Disable false context-manager pylint error 2018-10-12 12:00:25 -07:00
Lars Karlitski 160044ba9d Fix pylint errors and warnings
Remove `except` block which immediately raises the same exception again (it's
not a subclass of another caught exception, so this is safe).

Remove a false positive, because it is not emitted from the code base.

Disable subprocess-popen-preexec-fn in startProgram, which is not used
internally.
2018-09-25 13:49:40 +03:00
Brian C. Lane 4fea0ba7f1 pylorax: proc.returncode can be None
So use %s to keep it from generating a Traceback. If a callback is used
and it exits before the process does the returncode can be None.
2016-03-09 16:41:11 -08:00
Brian C. Lane 8cf8877e50 pylorax: Fix undefind strings on subprocess crash
Set output_string and err_string to None so that a crash will not crash.
2016-03-09 16:41:11 -08:00
David Shea f276f0f825 Fix the concatenation of error output.
The "x or y" construct does not have the precedence it looks like it
has.
2015-10-06 17:23:35 -04:00
Brian C. Lane 522ec34360 Return the output from failed commands in CalledProcessError
Some callers expect CalledProcessError.output to have the output, so
pass up the stdout + stderr output.

This means failed runcmd template commands will log to program.log and
lorax.log
2015-08-04 10:50:37 -07:00
Brian C. Lane cfe4777042 Add execReadlines to executils.
Returns output in realtime instead of buffering it.
2015-07-30 09:02:48 -07:00
Brian C. Lane 11b8eb8b97 Add reset_lang argument to everything in executils.
Running anaconda from lmc needs to override the language reset,
otherwise libuser crashes because it cannot support "C".
2015-07-27 11:27:43 -07:00
Brian C. Lane 3560d12608 Update execWith* docstrings 2015-05-15 17:11:21 -07:00
Brian C. Lane e1a05d962c Use the execWith* methods from Anaconda
The previous ones were a bit of a kludge, the Anaconda ones have had a
lot of work put into them so let's just use them with slight modifications.
2015-05-15 17:11:20 -07:00
Brian C. Lane de0e662f51 Convert pylorax to python3
Fix up 2to3 complaints. I've decided to do with wrapping list
comprehension inside list() to get the generators to run in several
places instead of list(map( or list(filter( which seem less readable to
me.
2015-05-15 17:11:20 -07:00
Brian C. Lane d96ed99621 Add log monitoring to lmc --no-virt installation
Previously if there was an error during a novirt installation that
didn't exit the process there was no way to detect it. This uses the new
--remotelog option for anaconda to monitor the logs for errors using the
same criteria as it does when monitoring a virt install. If there is an
error the anaconda process will be terminated and the logs will be
gathered up into ./anaconda/
2015-01-09 15:05:12 -08:00
Brian C. Lane d25c0b0594 Update copyright statements 2014-05-09 15:13:39 -07:00
Brian C. Lane 6d47689a33 Cleanup pylorax pylint warnings 2014-05-09 08:10:41 -07:00
Brian C. Lane 43bd549480 add convienience functions for running commands
Adds runcmd() and runcmd_output() which set raise_err=True
2012-09-17 11:26:53 -07:00
Brian C. Lane 381c4276ba add CalledProcessError to execWith* functions
This adds a raise_err argument that when set to True will raise a
CalledProcessError if the process's returncode is not 0
2012-09-17 11:26:41 -07:00
Brian C. Lane 134eec24d5 clean up command execution
Switch to using execWith* so that the command and its output can be
logged. To capture the output setup a logger named "program"

livemedia-creator captures all of this into program.log
2012-07-30 09:22:10 -07:00
Brian C. Lane 035d49628c Add execWith utils from anaconda
The anaconda execWithRedirect and execWithCapture functions are too
useful not to include. They also allow you to log all the execuatable's
output to a logfile. Added them under executils.py module which uses
the pylorax and a new program logger.
2011-12-20 14:59:57 -08:00