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
Return type

CompletedProcess

Returns

process result

Raises

subprocess.CalledProcessError – when command is checked and exits with error

The command in args is prefixed with env.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
Return type

CompletedProcess

Returns

process result

Raises

subprocess.CalledProcessError – when command is checked and exits with error

By default, commands are checked (i.e., raise when exiting with error) and stdout is captured in text 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