index : archinstall32 | |
Archlinux32 installer | gitolite user |
summaryrefslogtreecommitdiff |
author | jaybent <55739788+jaybent@users.noreply.github.com> | 2023-02-27 23:13:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-27 23:13:00 +0100 |
commit | f26b5308597273dfa182b89d265bcc59e057bd0e (patch) | |
tree | a066b9115de1c83656c64299f0471113157a3597 /archinstall | |
parent | fa1bec9679b2b8a85f450e7dd8aa24dc7c22d848 (diff) |
-rw-r--r-- | archinstall/lib/general.py | 32 | ||||
-rw-r--r-- | archinstall/lib/hsm/fido.py | 2 | ||||
-rw-r--r-- | archinstall/lib/installer.py | 8 |
diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py index 8c7aed91..bf32a9a8 100644 --- a/archinstall/lib/general.py +++ b/archinstall/lib/general.py @@ -185,12 +185,16 @@ class SysCommandWorker: def __init__(self, cmd :Union[str, List[str]], callbacks :Optional[Dict[str, Any]] = None, + peek_output :Optional[bool] = False, peak_output :Optional[bool] = False, environment_vars :Optional[Dict[str, Any]] = None, logfile :Optional[None] = None, working_directory :Optional[str] = './', remove_vt100_escape_codes_from_lines :bool = True): + if peak_output: + log("SysCommandWorker()'s peak_output is deprecated, use peek_output instead.", level=logging.WARNING, fg='red') + if not callbacks: callbacks = {} if not environment_vars: @@ -208,7 +212,9 @@ class SysCommandWorker: self.cmd = cmd self.callbacks = callbacks - self.peak_output = peak_output + self.peek_output = peek_output + if not self.peek_output and peak_output: + self.peek_output = peak_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.logfile = logfile @@ -262,7 +268,7 @@ class SysCommandWorker: except: pass - if self.peak_output: + if self.peek_output: # To make sure any peaked output didn't leave us hanging # on the same line we were on. sys.stdout.write("\n") @@ -307,7 +313,7 @@ class SysCommandWorker: self._trace_log_pos = min(max(0, pos), len(self._trace_log)) def peak(self, output: Union[str, bytes]) -> bool: - if self.peak_output: + if self.peek_output: if type(output) == bytes: try: output = output.decode('UTF-8') @@ -320,8 +326,8 @@ class SysCommandWorker: if peak_logfile.exists() is False: change_perm = True - with peak_logfile.open("a") as peak_output_log: - peak_output_log.write(output) + with peak_logfile.open("a") as peek_output_log: + peek_output_log.write(output) if change_perm: os.chmod(str(peak_logfile), stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP) @@ -412,11 +418,15 @@ class SysCommand: cmd :Union[str, List[str]], callbacks :Optional[Dict[str, Callable[[Any], Any]]] = None, start_callback :Optional[Callable[[Any], Any]] = None, + peek_output :Optional[bool] = False, peak_output :Optional[bool] = False, environment_vars :Optional[Dict[str, Any]] = None, working_directory :Optional[str] = './', remove_vt100_escape_codes_from_lines :bool = True): + if peak_output: + log("SysCommandWorker()'s peak_output is deprecated, use peek_output instead.", level=logging.WARNING, fg='red') + _callbacks = {} if callbacks: for hook, func in callbacks.items(): @@ -426,7 +436,9 @@ class SysCommand: self.cmd = cmd self._callbacks = _callbacks - self.peak_output = peak_output + self.peek_output = peek_output + if not self.peek_output and peak_output: + self.peek_output = peak_output self.environment_vars = environment_vars self.working_directory = working_directory self.remove_vt100_escape_codes_from_lines = remove_vt100_escape_codes_from_lines @@ -469,7 +481,7 @@ class SysCommand: return { 'cmd': self.cmd, 'callbacks': self._callbacks, - 'peak': self.peak_output, + 'peak': self.peek_output, 'environment_vars': self.environment_vars, 'session': True if self.session else False } @@ -478,7 +490,7 @@ class SysCommand: """ Initiates a :ref:`SysCommandWorker` session in this class ``.session``. It then proceeds to poll the process until it ends, after which it also - clears any printed output if ``.peak_output=True``. + clears any printed output if ``.peek_output=True``. """ if self.session: return self.session @@ -486,7 +498,7 @@ class SysCommand: with SysCommandWorker( self.cmd, callbacks=self._callbacks, - peak_output=self.peak_output, + peek_output=self.peek_output, environment_vars=self.environment_vars, remove_vt100_escape_codes_from_lines=self.remove_vt100_escape_codes_from_lines, working_directory=self.working_directory) as session: @@ -497,7 +509,7 @@ class SysCommand: while self.session.ended is None: self.session.poll() - if self.peak_output: + if self.peek_output: sys.stdout.write('\n') sys.stdout.flush() diff --git a/archinstall/lib/hsm/fido.py b/archinstall/lib/hsm/fido.py index 4cd956a3..758a2548 100644 --- a/archinstall/lib/hsm/fido.py +++ b/archinstall/lib/hsm/fido.py @@ -76,7 +76,7 @@ class Fido2: @classmethod def fido2_enroll(cls, hsm_device: Fido2Device, partition :Partition, password :str): - worker = SysCommandWorker(f"systemd-cryptenroll --fido2-device={hsm_device.path} {partition.real_device}", peak_output=True) + worker = SysCommandWorker(f"systemd-cryptenroll --fido2-device={hsm_device.path} {partition.real_device}", peek_output=True) pw_inputted = False pin_inputted = False diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 43542bc3..08f6d705 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -397,7 +397,7 @@ class Installer: raise RequirementError(f'Could not sync mirrors: {error}', level=logging.ERROR, fg="red") try: - return SysCommand(f'/usr/bin/pacstrap -C /etc/pacman.conf {self.target} {" ".join(packages)} --noconfirm', peak_output=True).exit_code == 0 + return SysCommand(f'/usr/bin/pacstrap -C /etc/pacman.conf {self.target} {" ".join(packages)} --noconfirm', peek_output=True).exit_code == 0 except SysCallError as error: self.log(f'Could not strap in packages: {error}', level=logging.ERROR, fg="red") @@ -921,15 +921,15 @@ class Installer: if has_uefi(): self.pacstrap('efibootmgr') # TODO: Do we need? Yes, but remove from minimal_installation() instead? try: - SysCommand(f'/usr/bin/arch-chroot {self.target} grub-install --debug --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB --removable', peak_output=True) + SysCommand(f'/usr/bin/arch-chroot {self.target} grub-install --debug --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB --removable', peek_output=True) except SysCallError: try: - SysCommand(f'/usr/bin/arch-chroot {self.target} grub-install --debug --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB --removable', peak_output=True) + SysCommand(f'/usr/bin/arch-chroot {self.target} grub-install --debug --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB --removable', peek_output=True) except SysCallError as error: raise DiskError(f"Could not install GRUB to {self.target}/boot: {error}") else: try: - SysCommand(f'/usr/bin/arch-chroot {self.target} grub-install --debug --target=i386-pc --recheck {boot_partition.parent}', peak_output=True) + SysCommand(f'/usr/bin/arch-chroot {self.target} grub-install --debug --target=i386-pc --recheck {boot_partition.parent}', peek_output=True) except SysCallError as error: raise DiskError(f"Could not install GRUB to {boot_partition.path}: {error}") |