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
checked and exits with error
The command in
argsis prefixed withenv.ROOTCMD.Behaves like
run_installerotherwise.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
checked and exits with error
By default, commands are
checked (i.e.,raisewhen exiting with error) andstdoutis captured intextmode.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