general: rework environment_vars (#3032)

This commit is contained in:
codefiles 2024-12-20 01:26:11 -05:00 committed by GitHub
parent f685849b8d
commit 367c8d781c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 7 deletions

View File

@ -107,13 +107,12 @@ class SysCommandWorker:
cmd: str | list[str],
callbacks: dict[str, Any] | None = None,
peek_output: bool | None = False,
environment_vars: dict[str, Any] | None = None,
environment_vars: dict[str, str] | None = None,
logfile: None = None,
working_directory: str | None = './',
remove_vt100_escape_codes_from_lines: bool = True
):
callbacks = callbacks or {}
environment_vars = environment_vars or {}
if isinstance(cmd, str):
cmd = shlex.split(cmd)
@ -126,7 +125,10 @@ class SysCommandWorker:
self.callbacks = callbacks
self.peek_output = peek_output
# define the standard locale for command outputs. For now the C ascii one. Can be overridden
self.environment_vars = {**storage.get('CMD_LOCALE', {}), **environment_vars}
self.environment_vars = {'LC_ALL': 'C'}
if environment_vars:
self.environment_vars.update(environment_vars)
self.logfile = logfile
self.working_directory = working_directory
@ -353,7 +355,7 @@ class SysCommand:
callbacks: dict[str, Callable[[Any], Any]] = {},
start_callback: Callable[[Any], Any] | None = None,
peek_output: bool | None = False,
environment_vars: dict[str, Any] | None = None,
environment_vars: dict[str, str] | None = None,
working_directory: str | None = './',
remove_vt100_escape_codes_from_lines: bool = True):

View File

@ -203,7 +203,7 @@ class Luks2:
debug(f'Adding additional key-file {key_file}')
command = f'/usr/bin/cryptsetup -q -v luksAddKey {self.luks_dev_path} {key_file}'
worker = SysCommandWorker(command, environment_vars={'LC_ALL': 'C'})
worker = SysCommandWorker(command)
pw_injected = False
while worker.is_alive():

View File

@ -14,6 +14,4 @@ storage: dict[str, Any] = {
'LOG_FILE': Path('install.log'),
'MOUNT_POINT': Path('/mnt/archinstall'),
'ENC_IDENTIFIER': 'ainst',
'CMD_LOCALE': {'LC_ALL': 'C'}, # default locale for execution commands. Can be overridden with set_cmd_locale()
'CMD_LOCALE_DEFAULT': {'LC_ALL': 'C'}, # should be the same as the former. Not be used except in reset_cmd_locale()
}