Skip to content

Commit

Permalink
Add reset_lang argument to everything in executils.
Browse files Browse the repository at this point in the history
Running anaconda from lmc needs to override the language reset,
otherwise libuser crashes because it cannot support "C".
  • Loading branch information
bcl committed Jul 27, 2015
1 parent 7fc78d7 commit 11b8eb8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
17 changes: 11 additions & 6 deletions src/pylorax/executils.py
Expand Up @@ -122,7 +122,8 @@ def preexec():
preexec_fn=preexec, cwd=root, env=env, **kwargs)

def _run_program(argv, root='/', stdin=None, stdout=None, env_prune=None, log_output=True,
binary_output=False, filter_stderr=False, raise_err=False, callback=None):
binary_output=False, filter_stderr=False, raise_err=False, callback=None,
env_add=None, reset_handlers=True, reset_lang=True):
""" Run an external program, log the output and return it to the caller
:param argv: The command to run and argument
Expand All @@ -145,7 +146,8 @@ def _run_program(argv, root='/', stdin=None, stdout=None, env_prune=None, log_ou
stderr = subprocess.STDOUT

proc = startProgram(argv, root=root, stdin=stdin, stdout=subprocess.PIPE, stderr=stderr,
env_prune=env_prune, universal_newlines=not binary_output)
env_prune=env_prune, universal_newlines=not binary_output,
env_add=env_add, reset_handlers=reset_handlers, reset_lang=reset_lang)

if callback:
while callback(proc) and proc.poll() is None:
Expand Down Expand Up @@ -190,7 +192,8 @@ def _run_program(argv, root='/', stdin=None, stdout=None, env_prune=None, log_ou
return (proc.returncode, output_string)

def execWithRedirect(command, argv, stdin=None, stdout=None, root='/', env_prune=None,
log_output=True, binary_output=False, raise_err=False, callback=None):
log_output=True, binary_output=False, raise_err=False, callback=None,
env_add=None, reset_handlers=True, reset_lang=True):
""" Run an external program and redirect the output to a file.
:param command: The command to run
Expand All @@ -207,10 +210,11 @@ def execWithRedirect(command, argv, stdin=None, stdout=None, root='/', env_prune
"""
argv = [command] + list(argv)
return _run_program(argv, stdin=stdin, stdout=stdout, root=root, env_prune=env_prune,
log_output=log_output, binary_output=binary_output, raise_err=raise_err, callback=callback)[0]
log_output=log_output, binary_output=binary_output, raise_err=raise_err, callback=callback,
env_add=env_add, reset_handlers=reset_handlers, reset_lang=reset_lang)[0]

def execWithCapture(command, argv, stdin=None, root='/', log_output=True, filter_stderr=False,
raise_err=False, callback=None):
raise_err=False, callback=None, env_add=None, reset_handlers=True, reset_lang=True):
""" Run an external program and capture standard out and err.
:param command: The command to run
Expand All @@ -224,7 +228,8 @@ def execWithCapture(command, argv, stdin=None, root='/', log_output=True, filter
"""
argv = [command] + list(argv)
return _run_program(argv, stdin=stdin, root=root, log_output=log_output, filter_stderr=filter_stderr,
raise_err=raise_err, callback=callback)[1]
raise_err=raise_err, callback=callback, env_add=env_add,
reset_handlers=reset_handlers, reset_lang=reset_lang)[1]

def runcmd(cmd, **kwargs):
""" run execWithRedirect with raise_err=True
Expand Down
3 changes: 2 additions & 1 deletion src/sbin/livemedia-creator
Expand Up @@ -614,7 +614,8 @@ def novirt_install(opts, disk_img, disk_size, repo_url):
os.environ["ANACONDA_PRODUCTVERSION"] = opts.releasever
log.info("Running anaconda.")
try:
execWithRedirect("anaconda", args, raise_err=True,
execWithRedirect("anaconda", args, raise_err=True, reset_lang=False,
env_add={"ANACONDA_PRODUCTNAME": opts.project, "ANACONDA_PRODUCTVERSION": opts.releasever},
callback=lambda p: not novirt_log_check(log_monitor.server.log_check, p))

# Make sure the new filesystem is correctly labeled
Expand Down

0 comments on commit 11b8eb8

Please sign in to comment.