Subprocesses¶
This module provides a simple wrapper around subprocess.run
to run commands in the installer or in the target system.
- fai.subprocess.run(args, **kwargs)¶
Run command in target system
- Parameters
kwargs¶ – additional arguments for
subprocess.run
- Return type
- Returns
process result
- Raises
subprocess.CalledProcessError – when command is
check
ed and exits with error
The command in
args
is prefixed withenv.ROOTCMD
.Behaves like
run_installer
otherwise.Example:
r = run(['getent', 'group', 'audio']) audio_group_members = r.stdout.split(':')[3].split(',')
- fai.subprocess.run_installer(args, **kwargs)¶
Run command in installer system
- Parameters
kwargs¶ – additional arguments for
subprocess.run
- Return type
- Returns
process result
- Raises
subprocess.CalledProcessError – when command is
check
ed and exits with error
By default, commands are
check
ed (i.e.,raise
when exiting with error) andstdout
is captured intext
mode.Example:
r = run_installer(['lsblk', '--json', '-O']) lsblk = json.loads(r.stdout)
Example with
kwargs
:r = run_installer(['systemd-detect-virt'], check=False) is_virt = r.returncode == 0